Question

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/. is it better to change on the codeigniter routes.php or the .htaccess file?

Was it helpful?

Solution

If you know that a URL should be redirected then there is no reason to hand the request to PHP. So, redirecting using the .htaccess file would be preferable.

If you have mod_alias installed then you can use the Redirect directive:

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. E.g.:

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. It will send the user to any website you like.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top