2013-04-15 86 views
0

我有這在我的.htaccess文件:的.htaccess和重寫規則

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /test/ 
RewriteCond %{REQUEST_URI} !(panel/index.php) 
RewriteRule ^panel/(.*)$ panel/index.php/$1/ [L] 
</IfModule> 

我想隧道含panel/(.*)panel/index.php控制它們的所有鏈接。

上述規則的工作原理除非url是http://localhost/test/panel/!它重定向到:

http://localhost/test/panel/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/

幫助需要。

+0

你爲什麼治療'index.php'作爲目錄?您可能希望重寫模板類似於'RewriteRule^panel /(.*)$ panel/index.php?q = $ 1 [L,QSA]',以便實際調用'index.php'。 –

+0

@ G-Nugget我做到了。但結果是一樣的。 – revo

+0

所以它不應該實際運行'index.php'? –

回答

1

試試這個

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    #skip rewrite for index.php 
    RewriteRule ^panel/index.php(.*)$ - [S=1,L] 
    RewriteRule ^panel/(.*)$ panel/index.php/$1/ [L] 
</IfModule> 
+0

同樣的結果! – revo

+0

測試編輯它爲我工作 –

+0

它也無法正常工作。根目錄是'test','panel'是它的一個子指針。 .htaccess放在根目錄下。這種情況下,它不適合我, – revo