Document root appending in url rewriting

纵然是瞬间 提交于 2020-01-14 18:48:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!