
May 09
URI Rewriting Alongside WordPress’ PermaLinks
For the sake of simplicity and logic I decided to follow the WordPress format but still stumbled across some problems. After some rookie errors I thought I would share this as it was one of those things I just kept missing!
Getting Along
Below is what WordPress wrote to the .htaccess file.
1 2 3 4 5 6 7 | <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /journal/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /journal/index.php [L] </IfModule> |
To add our own rewrites we need to rewrite the base path again. If the base directory is the public root directory (like http://www.example.net/) simply add a forward slash.
1 | RewriteBase / |
This is where I tripped up. After setting your rewrite conditions and then making a rewrite rule you must provide the absolute path from the public root directory. So don’t miss that forward slash!
1 | RewriteRule ^(.*)\.html$ /index.php?gibbs=$1 [L] |
And finally a simple rewrite would look something like this:
1 2 3 4 5 6 7 8 9 10 11 12 | <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)\.html$ /index.php?gibbs=$1 [L] RewriteBase /journal/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /journal/index.php [L] </IfModule> |
Bookmark or share this page:
MSN Contact: contact [at] danielgibbs.net
Dan Gibbs is a web developer, designer and SEO consultant involved in devon web design.






Kelly Brown 13 June 2009 3:45 am
The article is ver good. Write please more
Luis F. 30 August 2009 6:02 am
Nice write up…usually I never reply to these thing but this time I will,Thanks for the great info
Cath Kidston Bedding 13 October 2009 4:00 pm
I just ran into this, had 3 new blogs on the go that had url rewriter at the top level.
Thanks