How to remove “admin.php?page=” from wp-admin using .htaccess?

You can try this (sorry, not previously tested). See comments inline for explanation:

RewriteEngine On

## if any string separated by | is matched, it will append to ?page=
RewriteRule ^(members|add-members|delete)$ admin.php?page=%1 [L,E=CLEAN_CONTACT_URL:1,QSA]

## If querystring starts with page= and is followed by any string separated by |
## put that in the first group. Then put any other characters in second group
RewriteCond %{QUERY_STRING} ^page=(members|add-members|delete)(.*)$
RewriteCond %{ENV:REDIRECT_CLEAN_CONTACT_URL} !1
RewriteRule ^admin.php$ /wp-admin/%1?%2 [R,L]

You can probably rewrite the rule to be more generic. The main issue you’re having with:

RewriteCond %{QUERY_STRING} ^page=(.*)$

is that the (.*)$ matches ALL characters including your subsequent &foo=bar so the entire querystring is lumped into %1 and your %2 is empty.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)