我有一个.htaccess文件,在多个网站之间共享。 这些站点中的每一个都由同一组文件提供服务,但基于它们所运行的域名加载不同的configuration。
但是,我需要添加一些301redirect,我遇到了一个小问题。 我只想redirect执行一个特定的域,而不是每个.htaccess使用的域。 例如,我想redirectmysite1.com/some/pathredirect到mysite1.com/some/path ,但问题是,如果/some/path也存在mysite3.com它也redirect。
我基本需要的东西是这样的:
<if host = mysite1.com> Redirect /some/path http://mysite2/some/other/path </if>
这是可能的.htaccess中?
这是可能的 ,通过添加一个条件到你的RewriteRule例如。
RewriteEngine on RewriteCond %{HTTP_HOST} ^www.othersite1.com$ [OR,NC] RewriteCond %{HTTP_HOST} ^www.othersite2.com$ [NC] RewriteRule ^some/path http://mysite2/some/other/path [R]
这是做什么的: