Skip to content

Instantly share code, notes, and snippets.

@ictlyh
Last active April 5, 2017 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ictlyh/0fab7a2da38e212cc62f3fe090fc2093 to your computer and use it in GitHub Desktop.
Save ictlyh/0fab7a2da38e212cc62f3fe090fc2093 to your computer and use it in GitHub Desktop.
PHP page redirect with parameters
<?php
/* redirect mutouxiaogui.cn/blog to stay-stupid.com, the parameters remain unchanged */
/* notify search engines that a page has been permanently moved to another location */
header('Status: 301 Moved Permanently', false, 301);
/* redirect to another page */
$redirect_url = 'http://stay-stupid.com/'.basename($_SERVER['REQUEST_URI']);
header('Location: '.$redirect_url);
/* Make sure that code below does not get executed when we redirect. */
exit();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment