.htaccess在另一个域上重定向index.php?q = *到index.php?q = *

时间:2013-09-06 13:30:23

标签: .htaccess mod-rewrite modx

为什么每个页面都会重定向到域名?我移动dkcherta.ru - > dkchertanovo.ru并希望例如http://dkcherta.ru/index.php?id=80 - > http://dkchertanovo.ru/index.php?id=80

我的.htaccess:

    Options +FollowSymlinks -MultiViews
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?dkcherta\.ru$ [NC]
RewriteRule ^ http://dkchertanovo.ru/%{REQUEST_URI} [L,R=301]

RewriteRule ^rss_afisha[/]?$ /index.php?id=230 [L]
RewriteRule ^rss_news[/]?$ /index.php?id=231 [L]

ErrorDocument 404 http://dkchertanovo.ru/
# For full documentation and other suggested options, please see
# http://svn.modxcms.com/docs/display/MODx096/Friendly+URL+Solutions
# including for unexpected logouts in multi-server/cloud environments

RewriteBase /              

# Сливка доменного имени 
#RewriteCond %{HTTP_HOST} ^dkchertanovo\.ru$ [NC]
#RewriteRule ^(.*)$ http://www.dkchertanovo.ru/$1 [R=301,L]

RemoveHandler .php .htm .html
AddType application/x-httpd-php .php .htm .html
AddHandler application/x-httpd-php .php .htm .html
php_flag register_globals off

# Fix Apache internal dummy connections from breaking [(site_url)] cache
RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
RewriteRule .* - [F,L]

# Exclude /assets and /manager directories from rewrite rules
RewriteRule ^(manager|assets) - [L]

# For Friendly URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] 


### force www
    #RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
    #RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    #RewriteBase /


# Reduce server overhead by enabling output compression if supported.
#php_flag zlib.output_compression On
#php_value zlib.output_compression_level 5

1 个答案:

答案 0 :(得分:2)

您不需要多行:

Options +FollowSymLinks -MultiViews
RewriteEngine On 

只需在顶部放置一次,它对文件的其余部分应该有效。

然后要解决您的问题,请将此规则移到.htaccess文件中的所有其他规则之上:

RewriteCond %{HTTP_HOST} ^(www\.)?dkcherta\.ru$ [NC]
RewriteRule ^ http://dkchertanovo.ru%{REQUEST_URI} [L,R=301]