[英]htaccess redirect website
I'm trying to redirect all my visitors from the old domain that I use to the new one.我正在尝试将所有访问者从我使用的旧域重定向到新域。
Here is the content of the .htaccess file that I use这是我使用的 .htaccess 文件的内容
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !foobar.com$ [NC]
RewriteRule ^(.*)$ http://foobar.com/$1 [L,R=301]
where http://foobar.com is the new domain.其中http://foobar.com是新域。
The code above works but only if the visitor type http://olddomain.com .上面的代码有效,但前提是访问者输入http://olddomain.com 。
What I mean is when the visitor types我的意思是当访问者输入
http://olddomain.com/terms.php he should be redirected to http://foobar.com/terms.php http://olddomain.com/terms.php他应该被重定向到http://foobar.com/terms.php
I want that whatever the visitor types after the old domain name (like http://olddomain.com/privacy.php , http://olddomain.com/users.php , etc) they go to http://foobar.com/ not to http://foobar.com/privacy.php etc.我希望无论访问者在旧域名(如http://olddomain.com/privacy.php 、 http://olddomain.com/users.php等)之后输入什么,他们都会转到http://foobar.com /不是http://foobar.com/privacy.php等。
RewriteEngine On
RewriteCond %{HTTP_HOST} !^foobar\.com$ [NC]
RewriteRule .* http://foobar.com%{REQUEST_URI} [L,R=301]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.