2013-11-03 38 views
1

如何重定向到mydomainname.com/index.php mydomainname.com我想重定向到domain.com/index.php domain.com的

目前我使用如下代碼也。

<IfModule mod_rewrite.c> 

    RewriteEngine On 

    RewriteCond %{HTTP_HOST} !^mydomianname\.com 
    RewriteRule (.*) http://mydomianname.com/$1 [R=301,L] 

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?p=([^\s&]+) [NC] 
    RewriteRule^/%1? [R=301,L] 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ index.php?p=$1 [QSA,L] 
</IfModule> 

回答

1

這應該是你完全.htaccess

<IfModule mod_rewrite.c> 
    RewriteEngine On 

    RewriteCond %{HTTP_HOST} !^mydomianname\.com 
    RewriteRule (.*) http://mydomianname.com/$1 [R=301,L] 

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?p=([^\s&]+) [NC] 
    RewriteRule^/%1? [R=301,L] 

    # remove index.php 
    RewriteCond %{THE_REQUEST} /index\.php [NC] 
    RewriteRule ^(.*?)index\.php$ /$1 [L,R=301,NC,NE] 

    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ index.php?p=$1 [QSA,L] 
</IfModule> 
0

這個例子只適用於http,但應該大致做到這一點。

# Redirect requests with index.php to the corresponding request 
# without the index.php 
RewriteRule ^index.php(.*) http://mydomianname.com$1 [R=301,L] 
相關問題