I'm having some oddness with the URL rewriting in IIS 7. Here's my Web.config (below). You'll see "imported rule 3," which grabs attempts to access /sitemap.xml and redirects them to /sitemap/index. That rule works great.

Right below it is imported rule 4, which grabs attempts to access /wlwmanifest.xml and redirects them to /mwapi/wlwmanifest. That rule does NOT work.

(BTW, I do know it's "rewriting" not "redirecting" - that's what I want).

So... why would two identically-configured rules not work the same way? Order makes no different; Imported Rule 4 doesn't work even if it's in the first position.

Thanks for any advice!

EDIT: Let me represent the rules in .htaccess format so they don't get eaten :)

RewriteEngine On

# skip existing files and folders
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

# get special XML files
RewriteRule ^(.*)sitemap.xml$ /sitemap/index [NC]
RewriteRule ^(.*)wlwmanifest.xml$ /mwapi/index [NC] 

# send everything to index
RewriteRule ^.*$ index.php [NC,L]

The "sitemap" rewrite rule works fine; the 'wlwmanifest' rule returns a "not found." Weird.


Your rules weren't included in your post, but one thing to check for is if any rules higher up in the list are catching it first, that would throw you off.

  • Hmm. It "ate" my web.config. No, I'm certain nothing higher up is causing the problem - I moved this rule to the top of the list to try. – Don Jones Nov 23 '09 at 16:26
  • Can you include the rules? And, by not work I assume that it just doesn't catch it, or does it redirect incorrectly? – Scott Forsyth - MVP Nov 23 '09 at 18:32

Figured it out. The Web app is running on Zend Framework, and it isn't sufficient to have .htaccess rules as Zend has its own internal routing rules that have to be set up. So my middle two rules weren't even necessary, as they had to be configured within Zend's routes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.