Wordpress and permalinks without mod_rewrite
Thursday, 6. September 2007 22:21 - daniel - Blogs - 2 Comments
Even if your webhost doesn't let you use mod_rewrite, you can get nice URL with a simple hack. Mosty webhosts let you configure custom error pages. That means, if a visitors tries to access a page that doesn't exist, you can show him your special 404 page instead of the apache default.
We will use this for our permalinks. If you enable permalinks and mod_rewrite doesn't work, all you'll see is a 404 page. We'll now create custom error handlers for 404 to display index.php instead. Every time a visitor opens a permalink, he will trigger this custom error handler and he'll see the correct site. Wordpress doesn't care, if mod_rewrite or our custom error handler has redirected this user.
All you need to do is this:
Switch Wordpress to your preferred permalink structure.
Either write this into your .htaccess file (and delete everything that was in there):
ErrorDocument 404 /index.php
ErrorDocument 403 /index.php
ErrorDocument 401 /index.php
or, if you have a management panel like confixx or syscp, you can configure error documents there:
You should add this to your index.php file, right after the <?php in a new line
header( 'HTTP/1.1 200 OK' );
Comments
Richard - Friday, 8. February 2008 8:12
That is quite clever! Thanks for that idea.
Are there any SEO disadvantages for this? Or is this take care of by the header( 'HTTP/1.1 200 OK' ); status?
Also, what happens, if someone actually should land at a 404 error page? Does this make all URLs valid?
Daniel - Friday, 8. February 2008 21:34
The header() line overrides the 404 header the webserver sends.
Well, I'm not sure if this makes all pages valid. Wordpress still send a 404 error page to the user and an additional Status: 404 header. Not sure how crawlers react on this.