-
- $the_host = $_SERVER['HTTP_HOST']; //Mark to get the current domain name
- $request_url = isset($_SERVER['REQUEST_URI'])?$_SERVER['REQUEST_URI']: ''; //Determine the last part of the address
- if($the_host !== 'bbs.it-home.org') //The domain name address that has not been changed
- {
- header('HTTP/1.1 301 Moved Permanently'); / / Prompt to issue 301
- header('Location: http://bbs.it-home.org/'.$request_url); //Add new domain name address
- }
- ?>
Copy code
2. In which file should you add the 301 redirect command
Add 301 redirect instructions to the .htaccess file and use mod_rewrite (url rewriting) technology.
Example:
-
- RewriteEngine on
- RewriteRule ^(.*)$ http://bbs.it-home.org/$1 [R=301,L]
Copy code
|