RewriteRule - 使用破折号获取所有网址
我需要将所有带破折号的网址重定向到特定页面。
例如:site.com/this-url
到 site.com/page.php?url=this-url
RewriteRule
RewriteRule ^(.+-.+)$ page.php?url=$1
只需挂起 http。没有回应。
出了什么问题以及如何解决?
I need to redirect all urls with dash to a specific page.
For example:site.com/this-url
to site.com/page.php?url=this-url
RewriteRule
RewriteRule ^(.+-.+)$ page.php?url=$1
just hang http. No response.
What is wrong and how it can be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个,你可能会遇到无限循环。
现在:
QSA
标志将原始请求中的所有查询参数附加到重写的请求B
标志转义反向引用$1
以便可以安全地用作查询参数L
标志并不是绝对必要的,但可以避免在匹配此规则时评估其他重写规则Try this instead, you may have an infinite loop.
Now:
QSA
flags appends all the query parameters from the original request to the rewritten requestB
flag escapes the backreference$1
so that it can safely be used as a query paramaterL
flag is not strictly necessary, but avoids evaluating other rewrite rules when this one is matched您也可以尝试此选项:
You may also try this option: