2011-12-19 15 views
0

我嘗試做以下...ISAPI重寫,如果有.EXT文件存在,那麼允許它作爲一個文件夾的網址

如果叫一個頁面,然後login.asp存在允許重寫它作爲/登錄/但做不允許直接訪問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中的內容以檢查它是否是用戶配置文件。

非常感謝!

Ç

回答

0

嘗試使用:

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] 
+0

我已經更新的問題,以使其更清晰。 – 2011-12-19 14:56:04

相關問題