ISAPI 重写,如果带有 .ext 的文件存在,则允许它作为文件夹 URL
我正在尝试执行以下操作...
如果存在名为 login.asp
的页面,则允许将其重写为 /login/ 但不允许直接访问 login.asp< /代码>。
到目前为止,这是我的代码。
# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.87
RewriteEngine On
# if file is not exists
RewriteCond %{DOCUMENT_ROOT}/$1 !-f
# if folder is not exists
RewriteCond %{DOCUMENT_ROOT}/$1 !-d
# From start to end, "^(\w+)[/]+$" only matches with one or more alphanumeric characters and "_".
# Alternatively can end with one or more slashes.
# Change [R = 302, L] to [L] if you want make a rewrite instead of redirect.
RewriteRule ^(\w+)[/]*$ /username.asp?username=$1 [L]
因此,如果您想象用户输入 www.web.com/contact
,如果有一个名为 contact.asp
的页面,它会显示重写的内容。如果 .asp 页面不存在,则会从 /user.asp?username=contact
加载内容以检查它是否是用户配置文件。
非常感谢!
C
I am trying to do the following...
If a page called login.asp
exists then allow a rewrite for it as /login/ but do not allow a direct access to login.asp
.
Here is my code so far.
# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.87
RewriteEngine On
# if file is not exists
RewriteCond %{DOCUMENT_ROOT}/$1 !-f
# if folder is not exists
RewriteCond %{DOCUMENT_ROOT}/$1 !-d
# From start to end, "^(\w+)[/]+$" only matches with one or more alphanumeric characters and "_".
# Alternatively can end with one or more slashes.
# Change [R = 302, L] to [L] if you want make a rewrite instead of redirect.
RewriteRule ^(\w+)[/]*$ /username.asp?username=$1 [L]
So if you imagine the user types www.web.com/contact
if there is a page called contact.asp
it displays that rewritten content. If the .asp page does not exist then it loads the content from /user.asp?username=contact
to check if it is a user profile.
Much appreciated!
C
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用:
Try using: