seo - Redirect old urls after url rewriting -
i need deciding how redirect old urls new ones. @ moment have urls like
myhost.com/viewrecipe.php?id=2
but want them like
myhost.com/recipes/pear-pie
the problem website indexed in google. there way write 301 redirect search engines redirect them old type of urls new one?
if it's impossible achieve without using id in new url type, other option makethis transition smooth possible search engine?
p.s. dynamic urls
you can use .htaccess file in root of application containing:
redirect 301 viewrecipe.php?id=2 http://www.myhost.com/recipes/pear-pie
yes needed urls... if not can't try write rewrite neded id on new seo-friendly url.
another way able acces viewrecipie.php?id=2 , code like:
<?php // new name dependeind of id $slug = posts::getbyid($id); header("http/1.1 301 moved permanently"); header("location: http://www.myhost.com/recipes/".$slug); ?>
and shortest way:
header("location: http://www.myhost.com/recipes/".$slug",true,301);
Comments
Post a Comment