【问题标题】:URL Redirect Based on Target Domain Name基于目标域名的 URL 重定向
【发布时间】:2018-02-02 07:20:14
【问题描述】:
我有两个域 foo.com 和 bar.com 都指向“/var/www/html/”。在 Apache2 上托管的基本 HTML 页面很少。我想在“.htaccess”中进行重定向,当有人打开“foo.com”时,它不应该有任何重定向,它会在“/var/www/html/”中显示“index.html”。但是如果有人打开“bar.com”,它应该重定向到“http://foo.com/contactus/details.html”
谢谢。
【问题讨论】:
标签:
apache
.htaccess
redirect
【解决方案1】:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^bar.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.bar.com [NC]
RewriteRule ^(.*)$ http://foo.com/contactus/details.html [L,R=301,NC]
试试这个把一个 url 重定向到一个新的 url