Search code examples
wordpress.htaccessmod-rewriteiis-6isapi-rewrite

mod_rewrite issues using ISAPI_rewriter on IIS6


I'm hoping non-IIS people can help me on this though the issue I'm having is based around an IIS6 server running ISAPI_Rewriter.

The situation is that I'm running Wordpress on IIS6, ISAPI_Rewriter is being used to act as a replacement for mod_rewrite and is functioning properly. My problem is that when I get it to rewrite my URLs for Wordpress (so I don't need the index.php filename in it) it shows a 404. After much searching I found the problem was because part of the ASP.net (or something similar) was adding eurl.axd/[random string] to the end of the URLs and so this was being fed into the Wordpress request and breaking it. I set the Wordpress template to output the requested URL and it looks something like this:

http://www.example.com/index.php/about/eurl.axd/b552863f2d5e9841b5d8b79b44ac02e8/

I believe this is because of the pecking order of various things in the IIS system and the culprit is required to run another part of the project. I'd prefer to keep using ISAPI_Rewriter to pretty up the URLs so I'd like to know this:

Is there any way of getting mod_rewrite to remove eurl.axd/[string] before feeding it on to the system?

My .htaccess file currently appears as such:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# The following line excludes folders from rewriting
RewriteCond %{REQUEST_URI} !^/folder-name/

RewriteRule ^/(.*)$ /$1 [NC,L]

Thanks for all the help, it is always greatly appreciated.


EDIT: Have adjusted my htaccess based on suggestions and it seems to work well from the brief tests I have carried out. Have posted it below.

RewriteEngine on
RewriteBase /

# This is used to strip ASP.net eurl.axd bits
# from the URL so wordpress can use permalinks


# For the root
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/wp-admin/
RewriteRule ^eurl\.axd/[0-9a-f]+/$ index.php [NC,L]


# For internal permalinks
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/wp-admin/
RewriteRule ^(.*)/eurl\.axd/[0-9a-f]+/$ index.php/$1 [NC,L]

Solution

  • Something like this near the top of your list of rewrites should work:

    RewriteRule ^(.*)/eurl\.axd/[0-9a-f]+/$ /$1