【问题标题】:Rewrite Rules are not being picked up by the Server服务器未选择重写规则
【发布时间】:2015-05-27 05:31:57
【问题描述】:

我不确定为什么 mod_rewrite.c 没有正确定位链接

示例网址

http://developer.prodev/dev_www_trunk/justink/public_html/search/manufacturer/hewlett-packard

重写引擎

http://developer.prodev/dev_www_trunk/justink/public_html/search/index.php?advanced=0&manufacturer_rewrite=hewlett-packard

我已经在htaccess tester上测试了我的重写规则

但这不是相同的结果,我在我的 error_log.log 中得到重定向到 justink/search/manufacturer/... (public_html 不属于重写)。

# dev_www_trunk/justink/public_html/search/manufacturer/hewlett-packard 
RewriteRule ^(dev_[^/]*)/justink/public_html/search/manufacturer/?(.*)$ /$1/justink/public_html/search/index.php?advanced=0&manufacturer_rewrite=$2%{QUERY_STRING} [L]

【问题讨论】:

    标签: php regex apache mod-rewrite xampp


    【解决方案1】:

    来自日志:

    '^(dev_[^/]*)/justink/public_html/search/manufacturer/?(.*)$' to uri 'search/manufacturer/hewlett-packard'
    

    您的正则表达式中有很多前缀信息。如您所见,提供给您的正则表达式的 URL 只是

    'search/manufacturer/hewlett-packard'
    

    我相信您还希望重定向到新的 HTTP 位置而不是文件,以便您的 mod_phpphp-fpm 解释您的重定向请求:

    RewriteRule /search/manufacturer/?(.*)$ http://%{HTTP_HOST}/search/index.php?advanced=0&manufacturer_rewrite=$1%{QUERY_STRING} [L]
    

    【讨论】:

    • 我希望请求在localhost 上工作(域developer.prodevhosts 重新路径)。无论如何您可以改进答案,以便正则表达式适用于两条路径?
    • 谢谢马丁,我最终没有使用重写规则,你在答案中提出了......(但你的回答确实让我走上了一条更好的道路)。现在,我设计它们的网站有了更好的seo
    猜你喜欢
    • 1970-01-01
    • 2010-09-25
    • 2020-01-30
    • 2022-01-08
    • 1970-01-01
    • 1970-01-01
    • 2012-05-29
    • 2011-01-16
    • 1970-01-01
    相关资源
    最近更新 更多