1. Redirect www.111cn.net to www.111cn.net
Open the. htaccess file and add the following rules.
The code is as follows: |
Copy code |
RewriteEngine On RewriteCond % {HTTP_HOST }! ^ Www.111cn.net $ [NC] RewriteRule ^ (. *) $ http://www.111cn.net/#1 [L, R = 301] |
2. Redirect old.com to www.111cn.net
The code is as follows: |
Copy code |
RewriteEngine On RewriteCond % {HTTP_HOST }! 111cn.net $ [NC] RewriteRule ^ (. *) $ http://www.111cn.net/#1 [L, R = 301] |
To redirect a domain name without www to a domain name with www, you only need to replace the corresponding domain name with your own. If I want to jump a domain name with www to a domain name without www, I feel that it is not as simple as changing the location of two domain names, but it can be associated with the code in front of the domain name (as of % and ^) try changing the order
3. Redirect old.com/file/file.php to new.com/otherfile/other.php
The code is as follows: |
Copy code |
RewriteCond % {HTTP_HOST} ^ www.old.com $ RewriteRule ^ file/file. php $ http://www.new.com/otherfile/other.php [R = 301, L] |
The above code is to jump to directories and files. If your apache does not support htaccess files, we can directly set them in apache.
Use mod_rewrite to rewrite the URL
APACHE
The code is as follows: |
Copy code |
Options + FollowSymLinks RewriteEngine on RewriteCond % {HTTP_HOST} ^ baidu.com RewriteRule ^ (. *) $ http://www.baidu.com/#1 [R = permanent, L]
|
For more details, see: http://www.111cn.net/phper/apache/38888.htm
If you do not have the apache permission, you can implement it in php code.
The code is as follows: |
Copy code |
@ Header ("http/1.1 404 not found "); @ Header ("status: 404 not found "); Include ("404.html"); // jump to a page. This method is recommended. |
404.html file is an error prompt file