bruchowski
bruchowski

Reputation: 5351

Redirect all pages to one page with RedirectMatch

I'm trying to redirect all pages from a wordpress site to a single page in the admin area, here is the .htaccess rewrite rule I have that is not working, I'm not sure what I'm doing wrong? I have two .htaccess files in place with the same rules, one in the root, and one in the wp-admin directory

RewriteEngine on
RedirectMatch permanent !^/wp-admin/options-general.php?page=wpct_options/ /wp-admin/options-general.php?page=wpct_options/

permanent - A permanent redirect

!^/wp-admin/options-general.php?page=wpct_options/ - match any address that does not contain this in the url

/wp-admin/options-general.php?page=wpct_options/ - the url I want to redirect to

Upvotes: 0

Views: 316

Answers (1)

Michael Berkowski
Michael Berkowski

Reputation: 270647

I'm not sure you can use the bang ! to negate the expression in that position. That is typically used with RewriteCond, but I can't verify in the docs that it isn't permitted there. In any case, you can use a RewriteCond and negate that:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/wp-admin/options-general.php?page=wpct_options/
# Match with a 301 redirect
RewriteRule ^. wp-admin/options-general.php?page=wpct_options/ [L,R=301]

Upvotes: 1

Related Questions