Ben Dubuisson
Ben Dubuisson

Reputation: 757

htaccess mod_rewrite rule to just remove a question mark in 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

Upvotes: 0

Views: 299

Answers (1)

hex494D49
hex494D49

Reputation: 9245

Try the rule below

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

Upvotes: 1

Related Questions