2013-02-06 100 views
6

我想隱藏index.php頁面並只顯示域。.htaccess將index.php重定向到/

這是可能的.htaccess?

RewriteRule ^index\.php/?$/[L,R=301,NC] 

也試過:

RewriteEngine On 
RewriteBase/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.php HTTP/ 
RewriteRule ^index.php$ http://example.com/ [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 

index.php文件還顯示

回答

9

嘗試,這對我的作品!請確保您有在httpd.conf

RewriteEngine On 

    RewriteCond %{REQUEST_URI} index\.php 
    RewriteRule ^(.*)index\.php$ /$1/ [R=301,L] 

有規則中的正則表達式的問題AllowOverride All集,我已修改了規則和它的作品對我來說:

RewriteEngine On 
RewriteBase/
RewriteCond %{THE_REQUEST} index\.php 
RewriteRule ^index\.php$ http://example\.com/ [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index\.php [L] 
+0

都能跟得上。瀏覽器是否總能顯示index.php,而不是隻重定向到域? –

+0

你能發佈你的.htaccess文件嗎? – Satish

+0

張貼上面笏我有 –

3
RewriteRule ^(.*)index\.(html|php)$ http://%{HTTP_HOST}/$1 [R=301,L] 
相關問題