Mod Rewrite - 根据是否有 GET 参数进行重定向
我想将这些 URL 重定向:
http://example.com/search
到 http://example.com/?page=search
http:// example.com/search?q=keyword
到 http://example.com/?page=search&q=keyword
我试图在 .htaccess< 中使用它/strong> 但不起作用:
RewriteRule ^search$ ?page=search [nc]
RewriteRule ^search\?(.*)$ ?page=search&$1 [nc]
我做错了什么?
I want to redirect these URLs:
http://example.com/search
to http://example.com/?page=search
http://example.com/search?q=keyword
to http://example.com/?page=search&q=keyword
I am trying to use this in .htaccess but doesn't work:
RewriteRule ^search$ ?page=search [nc]
RewriteRule ^search\?(.*)$ ?page=search&$1 [nc]
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您希望将请求定向到 index.php 文件,并将该文件包含在规则中。例如,
尝试一下。
Assuming you want to direct the request to the index.php file include the file in the rules. E.g.
Give it a try.