admin管理员组文章数量:1022752
I've got a multisite sub-domain install with 3 sites on it. 2 of the sites use domain mapping.
The main site (id=1) requires several 301's that are old pages from a previous structure such as:
Redirect 301 /about/careers/ /contact/careers/
One of the other sites (id=3) has content that has moved into the main site. Normally, I'd redirect this in the .htaccess of that site:
Redirect 301 /news/events/ /
Multisite only has one .htaccess file. Is there a way to add 301 redirects for each individual site/domain from the main .htaccess file?
I've got a multisite sub-domain install with 3 sites on it. 2 of the sites use domain mapping.
The main site (id=1) requires several 301's that are old pages from a previous structure such as:
Redirect 301 /about/careers/ /contact/careers/
One of the other sites (id=3) has content that has moved into the main site. Normally, I'd redirect this in the .htaccess of that site:
Redirect 301 /news/events/ http://domain/news/events/
Multisite only has one .htaccess file. Is there a way to add 301 redirects for each individual site/domain from the main .htaccess file?
Share Improve this question asked Mar 20, 2013 at 16:47 Mr Jonny WoodMr Jonny Wood 1652 silver badges14 bronze badges 2 |3 Answers
Reset to default 3Okay,
RewriteEngine On
RewriteBase /
# Blog ID1 Rewrite Rules
RewriteCond %{HTTP_HOST} ^(www\.)?primary-domain.co.uk [NC]
RewriteRule ^about/careers/$ contact/careers/ [R=301,NC,L]
RewriteRule ^glossary.html$ sitemap/ [R=301,NC,L]
# Blog ID3 Rewrite Rules
RewriteCond %{HTTP_HOST} ^(www\.)?mapped-domain3.co.uk [NC]
RewriteRule ^about/$ http://primary-domain.co.uk/about/ [R=301,NC,L]
RewriteRule ^news/$ http://primary-domain.co.uk/news/ [R=301,NC,L]
This works, there's 158 more lines to my particular site but you get the idea. I hadn't found a clear solution to this but this article helped me massively.
Hope this helps anyone else looking for the same solution ;)
I used the above information to figure it out for my system as well. But in the implementation I found that I had to structure it as such.
RewriteEngine On
RewriteBase /
# Website site-1 Rewrite Rules
RewriteCond %{HTTP_HOST} ^(www\.)?domain [NC]
RewriteRule ^that-one-page-old/$ that-one-page-new/ [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?domain [NC]
RewriteRule ^that-other-page-old.php$ that-other-page-new/ [R=301,L]
If I didn't structure this way, that-one-page-old/ would function as it should but then the following rules (that-other-page-old.php) would apply to all domains on the system. With it listed as above then each rule only applied to the domain intended. Hope that helps anyone having the same issue as me.
I used this in the htaccess file for a wordpress multisite with subdomains to redirect a subdomain page to another main domain page.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.domain\ [NC]
RewriteRule ^redirect-from-subdmoain-page-url/(.*)$ https://domain/redirect-to-page-url/$1 [L,R]
I've got a multisite sub-domain install with 3 sites on it. 2 of the sites use domain mapping.
The main site (id=1) requires several 301's that are old pages from a previous structure such as:
Redirect 301 /about/careers/ /contact/careers/
One of the other sites (id=3) has content that has moved into the main site. Normally, I'd redirect this in the .htaccess of that site:
Redirect 301 /news/events/ /
Multisite only has one .htaccess file. Is there a way to add 301 redirects for each individual site/domain from the main .htaccess file?
I've got a multisite sub-domain install with 3 sites on it. 2 of the sites use domain mapping.
The main site (id=1) requires several 301's that are old pages from a previous structure such as:
Redirect 301 /about/careers/ /contact/careers/
One of the other sites (id=3) has content that has moved into the main site. Normally, I'd redirect this in the .htaccess of that site:
Redirect 301 /news/events/ http://domain/news/events/
Multisite only has one .htaccess file. Is there a way to add 301 redirects for each individual site/domain from the main .htaccess file?
Share Improve this question asked Mar 20, 2013 at 16:47 Mr Jonny WoodMr Jonny Wood 1652 silver badges14 bronze badges 2-
maybe use
mod_rewrite
instead andRewriteCond %{HTTP_HOST}
to apply a rewrite to specific hosts. – Milo Commented Mar 20, 2013 at 17:34 - Thanks @Milo but I have no idea about rewrite rules or htaccess files other than the basics, could you please expand a little? – Mr Jonny Wood Commented Mar 20, 2013 at 19:42
3 Answers
Reset to default 3Okay,
RewriteEngine On
RewriteBase /
# Blog ID1 Rewrite Rules
RewriteCond %{HTTP_HOST} ^(www\.)?primary-domain.co.uk [NC]
RewriteRule ^about/careers/$ contact/careers/ [R=301,NC,L]
RewriteRule ^glossary.html$ sitemap/ [R=301,NC,L]
# Blog ID3 Rewrite Rules
RewriteCond %{HTTP_HOST} ^(www\.)?mapped-domain3.co.uk [NC]
RewriteRule ^about/$ http://primary-domain.co.uk/about/ [R=301,NC,L]
RewriteRule ^news/$ http://primary-domain.co.uk/news/ [R=301,NC,L]
This works, there's 158 more lines to my particular site but you get the idea. I hadn't found a clear solution to this but this article helped me massively.
Hope this helps anyone else looking for the same solution ;)
I used the above information to figure it out for my system as well. But in the implementation I found that I had to structure it as such.
RewriteEngine On
RewriteBase /
# Website site-1 Rewrite Rules
RewriteCond %{HTTP_HOST} ^(www\.)?domain [NC]
RewriteRule ^that-one-page-old/$ that-one-page-new/ [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?domain [NC]
RewriteRule ^that-other-page-old.php$ that-other-page-new/ [R=301,L]
If I didn't structure this way, that-one-page-old/ would function as it should but then the following rules (that-other-page-old.php) would apply to all domains on the system. With it listed as above then each rule only applied to the domain intended. Hope that helps anyone having the same issue as me.
I used this in the htaccess file for a wordpress multisite with subdomains to redirect a subdomain page to another main domain page.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.domain\ [NC]
RewriteRule ^redirect-from-subdmoain-page-url/(.*)$ https://domain/redirect-to-page-url/$1 [L,R]
本文标签: multisite htaccess 301 redirects
版权声明:本文标题:multisite htaccess 301 redirects 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745562251a2156231.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
mod_rewrite
instead andRewriteCond %{HTTP_HOST}
to apply a rewrite to specific hosts. – Milo Commented Mar 20, 2013 at 17:34