这是我目前的设置:
<VirtualHost *:443>
ServerName www.product.com
Redirect "/something" "https://www.anotherredirectwebsite.com.com/something-name-product"
RedirectPermanent / https://www.redirectsite.com/
Include includes/product-config.inc
# Enable SSL
Include ssl-conf/product_ssl.conf
</VirtualHost>
# Redirect non-www to wwww
<VirtualHost *:443>
ServerName product.com
RedirectPermanent / https://www.product.com/
Include ssl-conf/product_ssl.conf
</VirtualHost>
# Redirect non-www http to https
<VirtualHost *:80>
ServerName product.com
RedirectPermanent / https://www.product.com/
</VirtualHost>
# Redirect www http to https
<VirtualHost *:80>
ServerName www.product.com
Define proxy_host www.product.com
RedirectPermanent / https://www.product.com/
</VirtualHost>
我希望每个人都可以将product.com重定向到某个网站。然而,当有人去product.com/something时,我希望他们被重定向到不同的网站。
现在问题是不会重定向product.com/anysubdirectory,但会显示原始网站。这也导致/某些东西也没有被重定向。
答案 0 :(得分:0)
试试这个
<VirtualHost *:80>
ServerName product.com
ServerAlias www.product.com
RedirectPermanent / https://www.product.com/
</VirtualHost>
<VirtualHost *:443>
ServerName product.com
ServerAlias www.product.com
RewriteEngine On
RewriteRule ^something/(.*) https://www.anotherredirectsite.com/something-name-product/$1 [R=301,L]
RedirectPermanent / https://www.redirectsite.com/
# SSL config
</VirtualHost>