我正在尝试将所有访问者从我使用的旧域名重定向到新域名。
下面是我使用的.htaccess文件的内容
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !foobar.com$ [NC]
RewriteRule ^(.*)$ http://foobar.com/$1 [L,R=301]其中http://foobar.com是新域。
上面的代码只有在访问者输入http://olddomain.com时才能正常工作。
我的意思是当访问者键入
http://olddomain.com/terms.php他应该被重定向到http://foobar.com/terms.php
我希望无论访问者在旧域名后输入什么(如http://olddomain.com/privacy.php,http://olddomain.com/users.php等),他们都会转到http://foobar.com/,而不是http://foobar.com/privacy.php等。
发布于 2012-11-27 01:11:27
RewriteEngine On
RewriteCond %{HTTP_HOST} !^foobar\.com$ [NC]
RewriteRule .* http://foobar.com%{REQUEST_URI} [L,R=301]https://stackoverflow.com/questions/13569183
复制相似问题