2017-09-26 94 views
0

跳過從URL目錄我有這樣http://localhost/test/htaccess/zero/one?id=100如何通過htaccess的

http://localhost/test/htaccess/一個URL就是現在的.htaccess文件存在,我想跳過zero文件夾,而想直接去一個項目文件夾。我已經綁

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

卸載的擴展,請幫我從URL中移除zero

+0

Werer是你位於php文件,你的php文件名是什麼? – Webdesigner

+0

zero是文件夾名稱,one.php是我的php文件,我跳過.php擴展名 – Maruf

回答

0

把.htaccess文件在/測試/ htaccess的/文件夾,內容如下:

RewriteEngine On 
# Ignore all real files 
RewriteCond %{REQUEST_FILENAME} !-f 
# Ignore if we are in subdirectory zero "/test/htaccess/zero" 
RewriteCond %{REQUEST_URI} !^/?test/htaccess/zero/(.*)$ 
# only apply if we are in "/test/htaccess/" 
RewriteCond %{REQUEST_URI} ^/?(test/htaccess)/(.*)$ 
# Rewrite to php file in zero subdirectory 
RewriteRule (.*) /%1/zero/$1.php [L] 

現在,如果您打開http://localhost/test/htaccess/one?id=100零子目錄中的one.php文件將作出響應。