Pergunta

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

Foi útil?

Solução

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]
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top