If you are in an Apache webserver, like me, probably you know what mod_rewrite is. This Apache module is able to output very nice URL that are SEO-friendly. For example now you are reading my blog and my blog run under the wordpress engine. Wordpress make intensive use of mod_rewrite. The main .htaccess file is:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
It stands for:
- I want to catch all requests to main folder
- if the request is not a real file
- or a real folder
- than pass the entire URI to index.php
this few rows of code produce a page like http://www.zaerl.com/lang/en/live/ and not some complicated and ugly GET requests. Now a problem arise a couple of days ago. I need to install in a subfolder a tool that do URL rewriting exactly as Wordpress do. Imagine that this tool is in a subfolder called foo/. It has an .htaccess file that is a perfect copy of the wordpress’ one. But it does not function. http://www.zaerl.com/foo/this/and/that/ spawn a “404 page not found” error cause the main .htaccess rewrite the URL no matter what there is in foo/.htaccess.
Well I’ve searched the solution to my problem in a lot of different forums but, incredibly, I didn’t find useful informations. I’ve tried complicated regular expressions in main .htaccess, tried different RewriteCond but nothing. Well the solution is simple. Very, very simple. On the .htaccess file of the subfolder foo/ I’ve written:
RewriteBase /foo
instead of:
RewriteBase /
and that’s it. Yes I know. KISS. This is one of those problems. Damn me. Now I can turn on URL rewriting in phpBB.
English
Italiano
3 responses ↓
1 Posts about SEO as of December 17, 2008 | The Lessnau Lounge on Dec 17, 2008 at 20:42 wrote
[...] [...]
2
Nicola
on May 7, 2010 at 13:18 wrote
Sei un grande! Ho bestemmiato un ora per quel problema. Stavo creando uno script per il tracciamento dei links e non capivo perchè in directory principale fungeva e in sottodirectory no. Poi ho trovato e provato questa soluzione….e mo funziona alla grande! GRAZIE MILLE!
3
programmer
on May 7, 2010 at 13:35 wrote
Grazie. È una di quelle classiche cose stupide che ti passano sotto gli occhi ma che non ci fai caso. Il manuale di Apache non è un granché.
Leave a Comment