Thursday, October 10, 2019

IIS URl Rewrite working inconsistently?



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.


Answer



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.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...