2016-11-27 75 views
1

我的網頁是這樣htaccess的URL從刪除文件夾,刪除.PHP

example.com/live/file1.php

,所以我希望用戶訪問像這樣的例子:

example.com/file1

我已經嘗試此添加在現場

RewriteRule ^(?!live/)(.*)$ live/$1 [L,NC] 

的根,這Ø ñ活動文件夾

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule ^(.*)$ $1.php [NC,L] 

,所以我覺得它的工作原理,但只是如果我example.com/file1.php訪問所以我刪除.PHP太 ,這是做

回答

1
RewriteEngine On 
RewriteRule ^$ live/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ live/$1 




RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule ^(.*)$ $1.php [NC,L] 
正道