Mod 重写 url
我在这里束手无策,我通常喜欢自己解决问题,但这让我在这里彻底失败了。 我正在尝试将包含加号的网址重写...
/search.php?q=can+be+any+length
至
/can-be-any-length.html
任何帮助将非常感激,因为重写了 + php 不是一个选项
I'm at my wits end here , I normally like to work things out on my own but this has me well and truly beaten here..
I'm trying to mod rewrite my urls that contain pluses...
/search.php?q=can+be+any+length
to
/can-be-any-length.html
Any help would be really appreciated becaus rewriting the + php is not an option
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 mod_rewrite 进行此类工作并不是最佳选择,因为您一次只能替换固定数量的字符。使用 PHP 肯定会更容易。
但是您可以使用 "N"(下一个) 标志重新启动替换,导致重写引擎在查询字符串中有“+”时循环:
Using mod_rewrite for this kind of work is not the best option as you can only replace a fixed amount of characters at at time. Using PHP would certainly be easier.
But you can use the "N" (Next) flag to restart replacement, causing the rewrite engine to loop while there's a "+" in the query string:
也许使用 RewriteMap :
文件 /path/to/file.txt 的内容
Maybe with RewriteMap :
Content of file /path/to/file.txt