本文介绍了通过路径更改将子域重定向到域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有子域的wordpress多站点安装。我想通过以下方式将我的子域之一重定向到域:
I have a wordpress multisite installation with subdomains. I want to redirect one of my subdomain to domain in the following manner:
- subdomain.domain.com => domain.com
- subdomain.domain.com/pages => domain.com/pages
- subdomain.domain.com/category-X/posts => domain.com/ category-X / posts
- subdomain.domain.com/category-Y/one-old-subcategory/posts => domain.com/one-new-subcategory/posts
- subdomain.domain.com/categories/subcategories/posts => domain.com/subcategories/posts
- subdomain.domain.com => domain.com
- subdomain.domain.com/pages => domain.com/pages
- subdomain.domain.com/category-X/posts => domain.com/category-X/posts
- subdomain.domain.com/category-Y/one-old-subcategory/posts => domain.com/one-new-subcategory/posts
- subdomain.domain.com/categories/subcategories/posts => domain.com/subcategories/posts
我找不到正确的顺序并重写规则来实现这一目标。
任何帮助将不胜感激。
I couldn't find correct order and rewrite rules to achieve that.Any help would be appreciate.
推荐答案
首先重定向所有特定内容:
First redirect everything that's specific:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com [NC]
RewriteRule ^categories/subcategories/(.*)$ http://domain.com/subcategories/$1 [L,R]
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com [NC]
RewriteRule ^category-Y/one-old-subcategory/(.*)$ http://domain.com/one-new-subcategory/$1 [L,R]
然后其他所有内容:
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R]
这篇关于通过路径更改将子域重定向到域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!