ISAPI 重写规则帮助 (http://www.foo.com/bar --> http://www.foo.com/bar.aspx)

发布于 2024-08-08 15:34:51 字数 607 浏览 12 评论 0原文

这确实很简单,但我需要正确执行此操作,并且不能承受错误,因为我需要尽快在实时服务器上进行部署。

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]

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=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]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纵性 2024-08-15 15:34:51

尝试这个规则:

RewriteCond $1 !.*\.aspx$
RewriteRule (.*) $1.aspx [L]

这应该避免任何可能的递归问题。如果您想排除已经存在的文件,请尝试以下条件:

RewriteCond %{REQUEST_FILENAME} !-f
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]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文