![](/img/trans.png)
[英]htaccess mod_rewrite two query string parameters to path format
[英]mod_rewrite: change a single query string parameters
我有这样的网址:
http://foo.bar/index.php?page=this-is-the-page
现在,我必须使用mod_rewrite查找这样的拼写错误的URL:
http://foo.bar/index.php?page=this--is-the-page
不幸的是,到目前为止,我无法找到正确的RewriteRule :
Options -MultiViews
RewriteEngine On
RewriteCond %{QUERY_STRING} ^page=(\w+)--((\w+)(-(\w+))*)$
RewriteRule ^index\.php$ /index.php?page=%1-%2
问题似乎是“?” 这应该表示QSD。 无论如何,在文章(例如mod_rewrite )中建议以这种方式更改查询字符串参数名称
那么,如何仅使用mod_rewrite重新组织查询字符串值? SEO友好和破解PHP代码在这里不是问题
尝试以下规则:
RewriteCond %{QUERY_STRING} ^page=(.*?)--([^&]*)
RewriteRule ^index\.php$ /index.php?page=%1-%2 [L,R]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.