2015-03-13 27 views
0

我有一個網頁,位於我的服務器中的example/files/page.php。我想使用Rewrite Rules來跳過URl中的/ files目錄,這樣當用戶鍵入example/page.php時,就可以查看page.php的內容。重寫規則怎麼可能這樣做?使用重寫規則在URl中跳過目錄

回答

0

將此項添加到您網站的根目錄的.htaccess中。

RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-d # not a dir 
RewriteCond %{REQUEST_FILENAME} !-f # not a file 
RewriteRule ^(example)/(.*)$ /$1/files/$2 [NC,L] 
+0

如果我沒有弄錯這段代碼應該位於/ example目錄下嗎? – jonas 2015-03-13 17:09:12

+0

添加了更新。 – 2015-03-13 18:30:25