RewriteRule,如何包含实体?

发布于 2024-09-30 10:13:57 字数 610 浏览 1 评论 0原文

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

搜索 URL:(xxx= 标签名称,例如苹果)

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。

I am tring to clean up url for my blog's search script using RewriteRule in .htaccess

Clean searching URL: (xxx= tag name ex. apple)

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

Regular Search URL script path:

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]

This works on majority of the words except when the word has '&'.
When entered as url '&' is converted as entity '%26' but when that is entered in to the browser as http://myblog.com/news/D%26G/ my .htaccess only recognizes 'D' and skips beyond.

How do I include '%26'in my RewriteRule?

I use Movable Type 5 by the way.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

︶葆Ⅱㄣ 2024-10-07 10:13:57

尝试使用 B 标志反向引用的值被转义:

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

Try using the B flag to have the values of backreferences escaped:

RewriteRule ^([^/]*)/$ /scripts/search.cgi?blog_id=4&tag=$1&limit=10 [L,B]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文