htaccess mod_rewrite规则只删除URL中的问号

htaccess mod_rewrite规则只删除URL中的问号

问题描述:

I am looking for a condition/rule to rewrite any urls

www.mywebsite.com/?admin/*

to

www.mywebsite.com/admin/*

so ?admin to admin

AKA remove that question mark from the URL (only when followed by admin obviously). I know it's a weird URL but that's a long story, all I need is to rewrite all admin URLs so that the query question mark is removed.

Thank you

我正在寻找重写任何网址的条件/规则 p>

www .mywebsite.com /?admin / * em> p>

p>

www.mywebsite.com/admin/ * em> p>

所以?admin to admin p>

AKA从URL中删除该问号(只有当显然是管理员后)。 我知道这是一个奇怪的网址,但这是一个很长的故事,我只需要重写所有管理网址,以便删除查询问号。 p>

谢谢 p>

Try the rule below

RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+\?(admin[^\s&]+) [NC]
RewriteRule ^ /%1? [R=301,L]