问题
I want to rewrite url from http://www.example.com/books/PHP/wrox to http://www.example.com/manuals/opensource/wrox
I have added the following rule
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^books/PHP/(.*)$ manuals/opensource/$1 [R=301,L]
The URL redirection appends my document root as
http://www.example.com/home/projects/www/publications/devel/manuals/opensource/wrox
My document root is /home/projects/www/publications/devel/ Thanks In advance for your help
回答1:
It has to do with the definition of the Directory statement you're Rewrite rule is in, according to this question on Server Fault.
回答2:
Try changing
RewriteRule ^books/PHP/(.*)$ manuals/opensource/$1 [R=301,L]
To
RewriteRule ^(.*)/books/PHP/(.*)$ $1/manuals/opensource/$2 [R,L]
来源:https://stackoverflow.com/questions/15187605/document-root-appending-in-url-rewriting