2014-09-24 51 views
0

我遇到的问题非常类似于here,该问题从未解决。301重定向为wordpress多站点子域

我有一个WordPress多站点安装与子域名,我试图让旧网址重定向到新的。

基本上,我使用

RewriteCond %{HTTP_HOST} 

定位的每个子域,与一批以下的RewriteRules的。

这里是我的一小段代码:

# Rewrite rules for French site 
RewriteCond %{HTTP_HOST} ^fr.nomacorc.com$ [nc] 
RewriteRule ^home\.php$ http://fr.nomacorc.com/ [R=301,NC,L] 
RewriteRule ^aboutus\.php$ http://fr.nomacorc.com/propos-de-nous/ [R=301,NC,L] 
RewriteRule ^ourclosures\.php$ http://fr.nomacorc.com/bouchons-pour-le-vin/ [R=301,NC,L] 

# Rewrite rules for German site 
RewriteCond %{HTTP_HOST} ^de.nomacorc.com$ [nc] 
RewriteRule ^home\.php$ http://de.nomacorc.com/ [R=301,NC,L] 
RewriteRule ^aboutus\.php$ http://de.nomacorc.com/uber-uns/ [R=301,NC,L] 
RewriteRule ^ourclosures\.php$ http://de.nomacorc.com/weinverschlusse/ [R=301,NC,L] 

我希望有发生的是de.nomacorc.com/aboutus.php重定向到de.nomacorc.com/uber-uns,而是将其重定向到fr.nomacorc.com/propos-de-nous/。 ourclosures.php重定向也发生了同样的情况。

我在做什么错这个代码?

回答

3

我在this other thread找到了答案。

我需要做的是将RewriteRules组链接到上面的RewriteCond。要做到这一点是这样描述得很好:

- Negate the condition (prepend it with !) 
- If you have multiple RewriteConds: 
- Change logical ANDs in the Conds to ORs and vice versa. 
- Add a skipping rewrite rule in front of all rules that you want to tie to the condition(s), set the S parameter to the number of Rule lines to be skipped. 

因此,这里是我纠正代码:

# Rewrite rules for French site 
RewriteCond %{HTTP_HOST} !^fr.nomacorc.com$ [nc] 
RewriteRule .? - [S=3] 
RewriteRule ^home\.php$ http://fr.nomacorc.com/ [R=301,NC,L] 
RewriteRule ^aboutus\.php$ http://fr.nomacorc.com/propos-de-nous/ [R=301,NC,L] 
RewriteRule ^ourclosures\.php$ http://fr.nomacorc.com/bouchons-pour-le-vin/ [R=301,NC,L] 

# Rewrite rules for German site 
RewriteCond %{HTTP_HOST} !^de.nomacorc.com$ [nc] 
RewriteRule .? - [S=3] 
RewriteRule ^home\.php$ http://de.nomacorc.com/ [R=301,NC,L] 
RewriteRule ^aboutus\.php$ http://de.nomacorc.com/uber-uns/ [R=301,NC,L] 
RewriteRule ^ourclosures\.php$ http://de.nomacorc.com/weinverschlusse/ [R=301,NC,L] 

我希望这可以帮助别人谁可能有同样的问题!