繁体   English   中英

mod_rewrite:更改单个查询字符串参数

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM