[英]Rewrite code for htaccess for specific parameter
I am non ech guy and trying to get a rewrite code which I can use in htaccess for file specific parameter. 我不是ech专家,并尝试获取可在htaccess中用于文件特定参数的重写代码。 Basically there are some urls with "?m=0" OR "?m=1" which I want to redirect.
基本上,我要重定向一些带有“?m = 0”或“?m = 1”的网址。 Like
喜欢
Old url: www.abc.com/nokia.html?m=1
New URL: www.abc.com/nokia.html
Old url: www.abc.com/nokia.html?m=0
New URL: www.abc.com/nokia.html
I want to redirect code which is applied only when these 2 specific m=1
OR m=0
are present. 我想重定向仅当存在这两个特定的
m=1
或m=0
时才应用的代码。 In case there is any thing else than m=1
or m=0
, the redirect shall not get applied. 如果
m=1
或m=0
之外的其他任何东西,则重定向将不会被应用。
I am using: 我在用:
RewriteCond %{THE_REQUEST} \ /([^\?\ ]*)\?
RewriteRule ^ /%1? [L,R=301]
But it gets applied in all urls and hence I can access admin pages where " ? " is used with other parameter. 但是它会应用到所有网址中,因此我可以访问将“ ? ”与其他参数一起使用的管理页面。
Can anyone plz mention the code which I can use in very specific cases. 任何人都可以提及我可以在非常特定的情况下使用的代码。 Thanks in advance.
提前致谢。
Use this rule: 使用以下规则:
RewriteCond %{QUERY_STRING} ^m=[01]$ [NC]
RewriteRule ^(.*)$ /$1? [R=301,L,NC]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.