使用 .htaccess 中的 Apache mod_rewrite 将其他域重定向到单个使用域
RewriteEngine On
RewriteCond %{HTTP_HOST} ^someparkeddomain.com
RewriteRule ^(.*)$ hxtp://www.thedomainUsed.co.uk/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.someparkeddomain.com
RewriteRule ^(.*)$ hxtp://www.thedomainUsed.co.uk/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^anotherparkeddomain.co.uk
RewriteRule ^(.*)$ hxtp://www.thedomainUsed.co.uk/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.anotherparkeddomain.co.uk
RewriteRule ^(.*)$ hxtp://www.thedomainUsed.co.uk/$1 [R=301,L]
是我所拥有的,但似乎没有做任何事情:/(hxtp,因为我是新用户而不是垃圾邮件发送者!)
重定向正在工作,因为我将它用于其他用途。
RewriteEngine On
RewriteCond %{HTTP_HOST} ^someparkeddomain.com
RewriteRule ^(.*)$ hxtp://www.thedomainUsed.co.uk/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.someparkeddomain.com
RewriteRule ^(.*)$ hxtp://www.thedomainUsed.co.uk/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^anotherparkeddomain.co.uk
RewriteRule ^(.*)$ hxtp://www.thedomainUsed.co.uk/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.anotherparkeddomain.co.uk
RewriteRule ^(.*)$ hxtp://www.thedomainUsed.co.uk/$1 [R=301,L]
is what I have but doesnt seem to do anything :/ (hxtp because I am new user not spammer!)
redirect is working though as I use it for something else.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
http://httpd.apache.org/docs/2.0/mod/mod_alias。 html
看看
http://httpd.apache.org/docs/2.0/mod/mod_alias.html
have a look at that
您的规则是正确的,尽管执行以下操作会更简单:
您不需要
L
标志,因为重定向始终是最终的。如果这不起作用,那是因为你把它放在了错误的地方。将它们放在默认(即第一个)虚拟主机中或(如果没有默认虚拟主机)主部分中,并确保您没有为
someparkeddomain.com
和 <代码>anotherparkeddomain.co.uk。Your rules are correct, though it would be simpler to do something like:
You don't need
L
flag because redirects are always final.If this is not working, it's because you're putting it in the wrong place. Put them in the default (i.e. first) virtual host or (if there is no default virtual host) in the main section and make sure you don't have virtual hosts set up for
someparkeddomain.com
andanotherparkeddomain.co.uk
.