使用 htaccess,我需要将所有不包含特定 URL 路径(医疗保健)的 URL 重定向到新域,同时保持原始 URL 不变。
Example:
healthcare.domain.com/anydirectory/anything.html
应该重定向到
staging.domain.com/anydirectory/anything.html
但任何包含 /healthcare 的 URL 不应被重定向。如 Healthcare.domain.com/industries/healthcare/customers.html 中所示,不应重定向。
两个域位于同一服务器上,并且healthcare.domain.com 指向与staging.domain.com 相同的根。他们希望能够访问 Healthcare.domain.com 上的 staging.domain.com/industries/healthcare/ 页面。我将healthcare.domain.com 设置为一个新的子域,将其根指向与staging.domain.com 相同的根。然后,我在 htaccess 中为healthcare.domain.com 设置一个重定向,以重定向到healthcare.domain.com/industries/healthcare,效果非常好,但是如果您单击/industries/healthcare/ 之外的网站上的任何其他位置,我需要带用户返回 staging.domain.com/whatever
这是我到目前为止所拥有的:
RewriteCond %{HTTP_HOST} ^healthcare\.domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.healthcare\.domain\.com$
RewriteRule ^/?$ "http\:\/\/healthcare\.domain\.com\/industries\/healthcare\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^healthcare\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !/healthcare/ [NC]
RewriteRule ^(.*)$ http://staging.domain.com/$1 [L,R=302]
但上面总是返回http://staging.domain.com/index.php http://staging.domain.com/index.php
Try:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^healthcare\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !/healthcare/
RewriteRule ^(.*)$ http://staging.domain.com/$1 [L,R]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)