codeigniter重定向的新域 [英] Codeigniter redirects for a new domain
问题描述
我有一个网站,有两部分 - 可以说A和B
I have a website which has 2 parts - lets say A and B.
现在我想移动的部分A到一个新的领域。
Now I want to move part A to a new domain.
目前,该网址的形式是:
Currently, the URLs are of the form:
www.xyz.com/A/controller/function - 为A部分
www.xyz.com/A/controller/function - for part A
www.xyz.com/A/B/controller/function - B部分
www.xyz.com/A/B/controller/function - for part B
我的新的链接将是:
www.abc.com/controller/function - 为A部分
www.abc.com/controller/function - for part A
www.xyz.com/B/controller/function - B部分
www.xyz.com/B/controller/function - for part B
您能否提供我一个很好的方法来处理这些重定向?我使用codeigniter框架。
Can you suggest me a good way to handle these redirects? I am using Codeigniter Framework.
推荐答案
尝试添加以下到你的的.htaccess
文件> www.xyz.com 网站。
Try adding the following to the .htaccess
file in the root directory of your www.xyz.com
site.
RewriteEngine on
RewriteBase /
#redirect www.xyz.com/A/B/controller/function
#www.xyz.com/B/controller/function
RewriteCond %{HTTP_HOST} ^www\.xyz\.com$ [NC]
RewriteRule ^A/(B/[\w]+/[\w]+)$ /$1 [L,NC,R=301]
#redirect www.xyz.com/A/controller/function to
#www.abc.com/controller/function
RewriteCond %{HTTP_HOST} ^www\.xyz\.com$ [NC]
RewriteRule ^A/([\w]+/[\w]+)$ http://www.abc.com/$1 [L,NC,R=301]
这篇关于codeigniter重定向的新域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!