ISHAN DOGRA ISHAN DOGRA - 1 year ago 121
Apache Configuration Question

.htaccess redirection for wordpress

Due to bug in our theme, We are trying to achieve these tasks

1.) when user click on login right now he is going to or ( WPML multilingual ). For all these types of URL its showing 404 page. So we thought we can remove language from URL using .htaccess redirection method.
So we are using following code

Redirect /en/wp-login.php /wp-login.php?redirect_to=
Redirect /fr/wp-login.php /wp-login.php?redirect_to=
Redirect /de/wp-login.php /wp-login.php?redirect_to=

using above code our login URL is working fine.

2.) But our registration URL is

So when we click on register link its also redirecting to

which is incorrect. We dont want to redirect register URL.

For this we also tried below code

RewriteCond %{QUERY_STRING} !(^|&)action=register($|&) [NC]
RewriteRule /en/wp-login\.php$ /wp-login.php?redirect_to= [L,R=301]

But this is also not working.
please tell what we are doing wrong.

Answer Source

Try this rule as your very first rule:

RewriteCond %{QUERY_STRING} !(^|&)action=register($|&) [NC]
RewriteRule ^en/wp-login\.php$ /wp-login.php?redirect_to= [L,R=301,NE,NC]

Leading slash / is not matched in .htaccess as it is per directory directive.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download