View Single Post
Old 02-02-2014, 09:42 AM  
fuzebox
making it rain
 
fuzebox's Avatar
 
Industry Role:
Join Date: Oct 2003
Location: seattle
Posts: 22,224
Quote:
Originally Posted by dunhill View Post
You can change the video.php script to something like:
PHP Code:
$id = $_GET['id']; //obviously clean this shit to avoid SQLI
//SQL Query: SELECT permalink FROM videos WHERE id='$id' LIMIT 1;
//$new_link = Query result || throw 404 header if id not found and exit script

header('HTTP/1.1 301 Moved Permanently');
header('Location: /videos/'.$new_link.'.html');
//If Bing won't rely on headers:
?><!DOCTYPE html>
<html>
<head>
<link href='http://site.com/videos/<?php echo $new_link;?>.html' rel='canonical'/>
</head>
<body>
<a href='http://site.com/videos/<?php echo $new_link;?>.html'>Moved</a>
</body>
</html>
<?php
die();
Update the sitemaps and set canonical url on the new pages.
I have moved some websites in a similar way but better to keep the old url format even if you update the script.
The old links looks less spammy in my opinion.
I concur
fuzebox is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote