« links for 2008-01-22 | Home | Seesmic Mobile Recording on my HTC Touch »
ISAPI_Rewrite for Wordpress
By chris dalby | January 23, 2008
I had an issue today while porting over a Wordpress blog that was using a .htaccess file. The blog had been setup to loose the /index.php from the folder structure which is a good thing to do, as some search engines refuse to index some URLs with a index.php?. So it improves your overall visibility and gives you a clean folder structure in your posts.
So I was porting over to the windows equivalent, ISAPI_Rewrite. This meant writing a completely new httpd.ini file.
This meant making changes to some wordpress 2.3.2 files to get all the important folders working correctly for style, images, api endpoint, admin etc.
To setup your httpd.ini file for ISAPI_Rewrite:
Change /wp-includes/classes.php
Change as follows (line 50 in Wordpress 2.3.2):
// $req_uri = $_SERVER['REQUEST_URI'];
$req_uri = $_SERVER['HTTP_X_REWRITE_URL'];
In your httpd.ini file, add the following rules:
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# Block external access to the httpd.ini and httpd.parse.errors files
RewriteRule /httpd(?:\.ini|\.parse\.errors).* / [F,I,O]
# Block external access to the Helper ISAPI Extension
RewriteRule .*\.isrwhlp / [F,I,O]
# Rules to ensure that normal content gets through
RewriteRule /software-files/(.*) /software-files/$1 [L]
RewriteRule /images/(.*) /images/$1 [L]
RewriteRule /favicon.ico /favicon.ico [L]
RewriteRule /robots.txt /robots.txt [L]
# For file-based wordpress content (i.e. theme), admin, etc.
RewriteRule /wp-(.*) /wp-$1 [L]
#Form the API endpoint
RewriteRule /xmlrpc(.*) /xmlrpc$1 [L]
# Rule to perform 301 redirect to ensure trailing back-slash on post and pages
RewriteCond Host: (.*)
RewriteRule ([^.?]+[^.?/]) http\://$1$2/ [I,R]
# Rule to perform 301 redirect (Remove index.php if specified)
RewriteRule /index.php/(.*) /$1 [I,RP]
# For normal wordpress content, via index.php
RewriteRule ^/$ /index.php [L]
RewriteRule /(.*) /index.php/$1 [L]
Some of this httpd.ini was found over on the wordpress forum, and some of it I added myself. Seems to work fine out the box.
Topics: Tech Watch |
September 30th, 2008 at 12:20 pm
i need a files httpd.ini for wordpress 2.6.2