I am changing urls and I would like to redirect already indexed page. For example domainname.com/categoryname/example.php?page=4 to domainname.com/categoryname/4.html. My code is below, please tell me if this is ok and safe for SEO. if (strpos($_SERVER['REQUEST_URI'],"example.php") ) { $string=$_SERVER['REQUEST_URI']; $parts = explode ('/', $string); $categoryname=$parts[1]; header('HTTP/1.1 301 Moved Permanently'); header('Location: http://www.domainname.com/'.$categoryname.'/'.$_GET[page].'.html'); } PHP:
If you changed from .php to .html than take following steps to switch without losing ranking of those pages There are two ways to do this: - Tell Apache to parse all .php files a .html file. to do this, place this code in your httpd.conf file: Code: AddType application/x-httpd-php .php .html - Use a 301 redirect to redirect from the .php files to the .html files. Code: RedirectMatch 301 ^/(.*)\.html$ http://www.yourdomain.com/$1.php