我正在尝试做以下事情…
如果存在一个名为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尝试使用:
RewriteEngine On
# if reqiested url+.asp exists
RewriteCond %{REQUEST_FILENAME}.asp -f
# if folder does not exist
RewriteCond %{REQUEST_FILENAME} !-d
Rewrite requested one-level url to target place
RewriteRule ^(w+)/?$ /username.asp?username=$1 [NC,L]