2013-02-06 36 views
6

Tôi muốn ẩn trang index.php và chỉ hiển thị tên miền..htaccess redirect index.php to/

Điều này có thể thực hiện với .htaccess không?

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

Cũng thử:

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 vẫn cho thấy

Trả lời

9

thử, nó làm việc cho tôi! Hãy chắc chắn rằng bạn có AllowOverride All bộ trong httpd.conf

RewriteEngine On 

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

Có một vấn đề regex trong các quy tắc của bạn, tôi đã sửa đổi quy tắc của bạn và nó làm việc cho tôi:

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

nope. trình duyệt có thể hiển thị index.php và không chuyển hướng đến miền không? –

+0

Bạn có thể đăng tệp .htaccess của mình không. – Satish

+0

đăng trên wat tôi có –

3
RewriteRule ^(.*)index\.(html|php)$ http://%{HTTP_HOST}/$1 [R=301,L] 
Các vấn đề liên quan