Original URL
mydomain.com/main/portfolio
Now I need to remove the controller name from the URL with the below Route which i have done successfully:
//Controller Name: main
$route['(:any)'] = "main/$1";
My new URL is good:
mydomain.com/portfolio
But the original URL is still accessible which I don’t want for SEO purposes:
mydomain.com/main/portfolio
How can I have my good URL run as normal and block the old URL.
Thanks.
2
Answers
You can create a not found page and redirect unwanted routes to that.
For instance you can create error controller:
Then in the routes.php you can catch those URLs which contains the “main/” like this:
More examples available here.