Quickquestion Posted September 7, 2009 Share Posted September 7, 2009 I want to take this: www.mysite.com/folder/someonesname and forward it to this: www.differentsite.com/folder/index.php?album=someonesname i.e. set up an index file that will create a dynamic redirect based on the end of the URL input. What's the best way to do this? I only know a small amount of PHP. Link to comment https://forums.phpfreaks.com/topic/173417-best-way-to-redirect-url/ Share on other sites More sharing options...
lynxus Posted September 7, 2009 Share Posted September 7, 2009 EDIT: Oops i completely misread the post. best thing to do is in the folder, put in a index.html file then add a meta refresh redirect to that index.html pointing to the other url. Probably summat like. <?php $url = $_GET['album']; header( 'Location: http://www.yoursite.com/'.$url.'.html' ) ; ?> Or along those lines. Link to comment https://forums.phpfreaks.com/topic/173417-best-way-to-redirect-url/#findComment-914191 Share on other sites More sharing options...
mattal999 Posted September 7, 2009 Share Posted September 7, 2009 That isn't the best way. It also isn't search engine friendly. Do this instead: <?php $album = $_GET['album']; // Presuming that you are using a mod_rewrite command to make folder/someonesname go to xx.php?album=someonesname header("HTTP/1.1 301 Moved Permanently"); // Send the permanently moved header for search engines and modern browsers header("Location: http://www.differentsite.com/index.php?album=".$album); // Redirect the user ?> Link to comment https://forums.phpfreaks.com/topic/173417-best-way-to-redirect-url/#findComment-914192 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.