[英]Using RewriteRules in httpd.conf
Everytime someone visits www.cars.com/parts I want them to be redirected to www.planes.com. 每当有人访问www.cars.com/parts时,我都希望他们被重定向到www.planes.com。 After that the paths are the same.
之后,路径是相同的。 For example www.cars.com/parts/engine should go to www.planes.com/engine and www.cars.com/parts/wheels should go to www.planes.com/wheels and so forth.
例如,www.cars.com / parts / engine应该转到www.planes.com/engine,而www.cars.com/parts/wheels应该转到www.planes.com/wheels,依此类推。 As of right now I have the following in my httpd.conf file:
截至目前,我的httpd.conf文件中包含以下内容:
RewriteEngine on
ServerName www.cars.com
DocumentRoot /var/www/htdocs
RewriteCond %{HTTP_HOST} www.cars.com/parts$ [NC]
RewriteRule ^/(.*)$ www.planes.com$1 [R=301,L]
However, the problem is that www.cars.com/parts is taking me to www.planes.com/parts and not www.planes.com. 但是,问题在于www.cars.com/parts会将我带到www.planes.com/parts,而不是www.planes.com。 Help would be much appreciated.
帮助将不胜感激。
Try changing the RewriteRule to : 尝试将RewriteRule更改为:
RewriteRule ^/parts(.*)$ www.planes.com$1 [R=301,L]
The $1 is substituted with the pattern detected in the parenthesis. $ 1替换为括号中检测到的模式。 So now it should append everything after /parts.
因此,现在应该在/ parts之后附加所有内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.