0
votes

Using a standard WordPress setup I had the following in htaccess...

RewriteCond %{QUERY_STRING} ^registration=disabled$ [NC]
RewriteRule ^wp-login.php$ http://www.mysite.com/register [L,R=301,NC]

Which successfully redirected any calls to wp-login.php?registreation=disabled to http://www.mysite.com/register

I have now moved over to multi-site so need the redirect to send the user to whatever site within the network they are browsing, how can i do this?

UPDATE

To clarify, as I am now using multi-site I could now be faced with different sub-domains and addresses such as

www.mydomain1.com/testsite www.mydomain2.com/example www.mydomain3.com/various

I am looking for a one size fits all htaccess command that will redirect

1

1 Answers

1
votes

You can just remove the domain from your RewriteRule:

RewriteCond %{QUERY_STRING} ^registration=disabled$ [NC]
RewriteRule ^wp-login.php$ /register [L,R=301,NC]

Tested here and it seems to work, although it doesn't trim off the query string (but then, neither does the original). If you want the query string removed, make the RewriteRule the following:

RewriteRule ^wp-login.php$ /register? [L,R=301,NC]

Edit: I can't test this on a real system at the moment, and unfortunately the link I provided doesn't support ${HTTP_HOST}, however you could add another condition which matches any http_host, and use a back-reference in the RewriteRule to put in that value:

RewriteCond %{QUERY_STRING} ^registration=disabled$ [NC]
RewriteCond %{HTTP_HOST} (.*)
RewriteRule ^wp-login.php$ http://%1/register? [L,R=301,NC]

As mentioned, I can't currently test this, but in theory it should work :)