Codeigniter redirects for a new domain

一世执手 提交于 2019-12-25 01:39:08

问题


I have a website which has 2 parts - lets say A and B.

Now I want to move part A to a new domain.

Currently, the URLs are of the form:

www.xyz.com/A/controller/function - for part A

www.xyz.com/A/B/controller/function - for part B

my new links will be:

www.abc.com/controller/function - for part A

www.xyz.com/B/controller/function - for part B

Can you suggest me a good way to handle these redirects? I am using Codeigniter Framework.


回答1:


Are you using the same CI install for both parts? If so then this link may help you.

If each part has its own CI install, don't forget you can use the same system folder for both by setting the $system variable in the index.php file




回答2:


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]


来源:https://stackoverflow.com/questions/9172019/codeigniter-redirects-for-a-new-domain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!