[英]url redirect, change it in codeigniter or change .htaccess
i have to redirect one url to another. 我必须将一个网址重定向到另一个。 http://www.abc.com/realestate/ to Redirect to http://www.abc.com/businessfinder/company/4105/Property_Agent/ .
http://www.abc.com/realestate/重定向到http://www.abc.com/businessfinder/company/4105/Property_Agent/ 。 is it better to change on the codeigniter routes.php or the .htaccess file?
更改codeigniter route.php或.htaccess文件是否更好?
If you know that a URL should be redirected then there is no reason to hand the request to PHP. 如果您知道应该重定向URL,则没有理由将请求提交给PHP。 So, redirecting using the
.htaccess
file would be preferable. 因此,最好使用
.htaccess
文件进行重定向。
If you have mod_alias
installed then you can use the Redirect
directive : 如果已安装
mod_alias
则可以使用Redirect
指令 :
Redirect 301 /realestate/ http://www.abc.com/businessfinder/company/4105/Property_Agent/
You can also use mod_rewrite
to jump between places in various ways. 您还可以使用
mod_rewrite
以各种方式在位置之间跳转 。 Eg: 例如:
RewriteRule ^/realestate/?$ /businessfinder/company/4105/Property_Agent/ [R=301,L]
If that is not possible then you can use CodeIgniter's $this->url->redirect()
method. 如果不可能,则可以使用CodeIgniter的
$this->url->redirect()
方法。 It will send the user to any website you like. 它将把用户带到您喜欢的任何网站。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.