htaccess&网站移动到子域后,干净的网址/不工作

时间:2011-08-29 20:53:33

标签: .htaccess subdomain

我不得不将网站移动到新的子域名。以前可以在www.some-domain.com获得。它现在已移至http://shop.some-domain.com

网站中只有一些内容实际上使用了干净的网址,例如:http://shop.some-domain.com/en-GB/shop/accessories/Soft-Scarf

并且正好这些网址不再有效,我在尝试打开它时收到错误404。网站的其他部分不使用干净的网址。

网站文件位于根文件夹(/)...此文件夹中的htaccess如下所示:

AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.some-domain.com [NC]

# i think this line is causing the problem:
RewriteRule ^(.*)$ http://www.some-domain.com/$1 [R=301,L]

ErrorDocument 404 /webEdition/redirectSEOurls.php

尝试将行中的网址更改为shop.some-domain.com,但没有帮助

非常感谢帮助,谢谢

1 个答案:

答案 0 :(得分:0)

您对错误来源是正确的。只需将www的两次出现更改为shop

RewriteEngine On
RewriteCond %{HTTP_HOST} !^shop\.some-domain.com [NC]

RewriteRule ^(.*)$ http://shop.some-domain.com/$1 [R=301,L]

RewriteCond行和后续RewriteRule的目的是强制http://some-domain.com之类的请求到规范域http://www.some-domain.com。您现在已将其更改为shop.some-domain.com,因此更新条件和重写规则很简单。