【问题标题】:Document root appending in url rewritingurl重写中附加的文档根
【发布时间】:2013-02-17 17:13:13
【问题描述】:

我想将 url 从 http://www.example.com/books/PHP/wrox 重写为 http://www.example.com/manuals/opensource/wrox

我添加了以下规则

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^books/PHP/(.*)$    manuals/opensource/$1 [R=301,L]

URL 重定向将我的文档根目录附加为

http://www.example.com/home/projects/www/publications/devel/manuals/opensource/wrox

我的文档根目录是 /home/projects/www/publications/devel/ 提前感谢您的帮助

【问题讨论】:

    标签: regex .htaccess url-rewriting


    【解决方案1】:

    根据this question on Server Fault,它与您正在重写规则所在的目录语句的定义有关。

    【讨论】:

    • 我尝试在带有文档根目录的目录中添加规则,它给了我 500 错误
    • 你能从你的 httpd.conf 发布完整的 sn-p 吗?那么,整个目录声明?
    【解决方案2】:

    尝试改变

    RewriteRule ^books/PHP/(.*)$    manuals/opensource/$1 [R=301,L]
    

    RewriteRule ^(.*)/books/PHP/(.*)$ $1/manuals/opensource/$2 [R,L] 
    

    【讨论】:

      猜你喜欢
      • 2019-08-14
      • 1970-01-01
      • 2014-09-27
      • 2011-09-11
      • 1970-01-01
      • 2012-05-31
      • 1970-01-01
      • 2020-06-10
      • 2011-07-29
      相关资源
      最近更新 更多