我有以下問題。比方說,我有鏈接像.htaccess如何只匹配URL中index.php的第一次出現?
http://localhost/test/index.php/admin
我有以下的htaccess:
Options -MultiViews
Options +FollowSymLinks
Options -Indexes
RewriteBase /test/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [NC,QSA,L]
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) $1$2 [R=301,NE,L]
它的作用是簡單地從URL中刪除index.php文件。然而,當我輸入網址這樣的:
http://localhost/test/abc/blabla/index.php
它繼續無限循環。我想要的是當URL中另一個index.php被滿足時什麼也不做。我怎樣才能做到這一點?謝謝!
'重寫規則^ $'是要匹配** **一切的URL。所以當重定向發生到index.php/index.php時,你會匹配,重定向到index.php/index.php/index.php等等...你需要排除'^ index.php' – 2014-12-01 19:55:14
@MarcB你能告訴我該怎麼做嗎? – 2014-12-02 17:42:11