一个非常简单的,但我需要做到这一点,并且不能承受错误,因为我需要尽快部署在实时服务器上。
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=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
我来到这里,但这会将bar.aspx
变成bar.aspx.aspx
,但这并不好。
# Helicon ISAPI_Rewrite configuration file
RewriteEngine on
RewriteRule (.*) $1.aspx [L]
答案 0 :(得分:2)
尝试此规则:
RewriteCond $1 !.*\.aspx$
RewriteRule (.*) $1.aspx [L]
这应该避免任何可能的递归问题。如果您想要排除现有文件,请尝试以下条件:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.aspx [L]