I need help with deciding how to redirect my old urls to the new ones.
At this moment I have the urls like
myhost.com/viewrecipe.php?id=2
But I want them to look like
myhost.com/recipes/pear-pie
The problem is that the website is already indexed in Google. Is there any way to write a 301 redirect for search engines to redirect them from the old type of urls to the new one?
If it’s impossible to achieve without using id in the new url type, what are other option to makethis transition as smooth as possible for search engine?
P.S. all those are dynamic urls
You can use a .htaccess file in the root of your application containing:
Yes this will be needed for all your URLs… if not you can’t try to write a rewrite but you will neded the id on the new seo-friendly url.
Another way will be to be able to acces to viewrecipie.php?id=2 and code something like:
And a shortest way: