PHP uses Apache's .htaccess pseudo-static function to achieve "when the webpage is not found, jump to other links"

demand:

1. For example, my previous website domain name is "www.zy13.net", and the link to an article is http://www.zy13.net/article-5-1.html

2. Due to business adjustments or other reasons, the domain name and website structure are changed, and the domain name is changed to "www.18pay.net", then others visit the article link http://www.zy13.net/article-5-1.html It will not be accessible at that time. The following 404 occurs:

solution: 

1. Create a new .htaccess pseudo-static configuration file in the root directory of the website (you can also add it in the pseudo-static settings of the pagoda), and add the following code:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)?zy13.net$    //如果域名是zy13.net
RewriteCond %{REQUEST_FILENAME} !-f //访问的页面(或文件)找不到
RewriteRule ^(.*)$ http://www.18pay.net/$1 [R=302,L] //携带原来的URL参数进行重定向到新的网址

Supplement: Pseudo-static rules for verifying the source URL

RewriteCond %{HTTP_REFERER} !^http://(.+.)?18pay.net/ [NC] //如果来源网址不是*.18pay.net

 

 

Guess you like

Origin blog.csdn.net/qq15577969/article/details/112665840