使用 .htaccess 中的 Apache mod_rewrite 将其他域重定向到单个使用域

发布于 2024-09-03 12:33:52 字数 589 浏览 1 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱,才寂寞 2024-09-10 12:33:52

您的规则是正确的,尽管执行以下操作会更简单:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)someparkeddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^(?:www\.)anotherparkeddomain.co.uk$ [OR]
RewriteRule ^/(.*)$ http://www.thedomainused.co.uk/$1 [R=301]

您不需要 L 标志,因为重定向始终是最终的。

如果这不起作用,那是因为你把它放在了错误的地方。将它们放在默认(即第一个)虚拟主机中或(如果没有默认虚拟主机)主部分中,并确保您没有为 someparkeddomain.com 和 <代码>anotherparkeddomain.co.uk。

Your rules are correct, though it would be simpler to do something like:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)someparkeddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^(?:www\.)anotherparkeddomain.co.uk$ [OR]
RewriteRule ^/(.*)$ http://www.thedomainused.co.uk/$1 [R=301]

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 and anotherparkeddomain.co.uk.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文