【问题标题】:RewriteRule, how do I include entities?RewriteRule,我如何包含实体?
【发布时间】:2010-11-06 16:52:04
【问题描述】:

我正在尝试使用 .htaccess 中的 RewriteRule 为我的博客搜索脚本清理 url

干净的搜索 URL:(xxx= 标记名称 ex.apple)

http://myblog.com/news/xxx/

常规搜索 URL 脚本路径:

http://myblog.com/scripts/search.cgi?blog_id=4&tag=xxx&limit=10 [L]

.htaccess

RewriteRule ^([^/]*)/$ /scripts/search.cgi?blog_id=4&tag=$1&limit=10 [L]

这适用于大多数单词,除非单词有“&”。 当输入为 url '&' 被转换为实体 '%26' 但是当它作为 http://myblog.com/news/D%26G/ 输入到浏览器中时,我的 .htaccess 只能识别 'D' 并跳过。

如何在我的 RewriteRule 中包含“%26”?

顺便说一句,我使用的是 Movable Type 5。

【问题讨论】:

    标签: regex .htaccess mod-rewrite movabletype


    【解决方案1】:

    尝试使用B flag 将反向引用的值转义:

    RewriteRule ^([^/]*)/$ /scripts/search.cgi?blog_id=4&tag=$1&limit=10 [L,B]
    

    【讨论】:

    • 感谢重播。如何将 B 标志合并到我的规则中?我是新手。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-01
    • 2017-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多