ISAPI Rewrite rule help (http://www.foo.com/bar --> http://www.foo.com/bar.aspx)
A really easy one, but I need to get this right, and cannot afford mistakes as I need to deploy on a live server as soon as I can.
http://www.foo.com/bar --> http://www.foo.com/bar.aspx
http://www.foo.com/bar?q=boo --> http://www.foo.com/bar.aspx?q开发者_StackOverflow中文版=boo
# I only want /bar to get rewritten to /bar.aspx
# everything else stays as is
http://www.foo.com/bar.aspx --> http://www.foo.com/bar.aspx
http://www.foo.com/bar.pdf --> http://www.foo.com/bar.pdf
I got here, but this turns bar.aspx
into bar.aspx.aspx
, and that ain't good.
# Helicon ISAPI_Rewrite configuration file
RewriteEngine on
RewriteRule (.*) $1.aspx [L]
Try this rule:
RewriteCond $1 !.*\.aspx$
RewriteRule (.*) $1.aspx [L]
That should avoid any possible problems with recursion. And if you want to exclude already existing files, try this condition instead:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.aspx [L]
精彩评论