2016-11-27 128 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] 
正道