Pergunta

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]
Foi útil?

Solução

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

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

Outras dicas

I use the following regex as first rule with Ionics Isapi Rewriter for web sites running on ASP.NET 4 on IIS 6 to remedy the problems caused by the breaking change introduced with ASP.NET 4 :

RewriteRule ^(.*)/eurl.axd/[a-f0-9]{32}(.*)$ $1$2

This let me again use extensionless urls.

Note that the second group captures the querystring if present and restitutes it to the rewritten url.

And yes, it's a feature, not a bug.

I ran into a similar issue with v4.0 ASP.Net extension less URL feature on II6 and found a solution through ISAPI Rewrite Module provider, the does not require turning it off. Theissue and the solution as we experienced it is documented here http://www.vanadiumtech.com/OurBlog/post/2011/08/12/Cause-of-eurlaxd.aspx

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top