2010-08-16 27 views
0

今年已經透明地重定向請求/file/file.php - 訪問/file顯示/file.php。我的.htaccess:硬盤重定向到file.php /文件(當/文件已經被透明地重定向到/file.php)

RewriteEngine on 
RewriteBase/
RewriteRule ^([a-zA-Z]+)/?$ $1.php [L] 

現在想辦一個硬重定向/file.php/file - 如果我打了/file.php,URL地址欄必須顯示/file。試過以下,但沒有工作:

RewriteEngine on 
RewriteBase/
RewriteRule ^([a-zA-Z]+)\.php$ $1 [R] 
RewriteRule ^([a-zA-Z]+)/?$ $1.php [L] 

任何幫助嗎?

回答

0

你需要基於用戶發送到服務器的請求來執行你的重寫。像這樣的東西應該工作:

RewriteEngine On 

RewriteCond %{THE_REQUEST} ^[A-Z]+\s/([a-zA-Z]+)\.php 
RewriteRule ^([a-zA-Z]+)\.php$ /$1 [R=301,L] 

RewriteRule ^([a-zA-Z]+)/?$ $1.php [L]