Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I use WordPress Multisite... and BuddyPress installed on the main site on

Practically I want users to be automatically redirected to the main site login page every time they try to login from any of the blogs/sites/subdomains.

* =>

Let me give some exemples: redirected to redirected to redirected to


any future subdomain LOGIN PAGE - with no exceptions - will have to be redirected to

share|improve this question

1 Answer 1

You could you do this with redirects through the root .htaccess file;

Something like this perhaps:

# Redirect to new login

<IfModule mod_rewrite.c>

# For security reasons, Option followsymlinks cannot be overridden.

# Options +FollowSymLinks

Options +SymLinksIfOwnerMatch

RewriteEngine on

RewriteCond %{HTTP_HOST} ^ [OR]

RewriteCond %{HTTP_HOST} ^ [NC]

RewriteRule ^(.*)$$1 [L,R=301]


# Redirect end

Or to redirect all sub-domains to the parent, you could try this as a "catch all":

RewriteCond %{HTTP_HOST} !^my-main-site\.com$ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

Or if you want to exclude some sub-domains you could do this:

RewriteCond %{HTTP_HOST} !^my-main-site\.com$ [NC]
RewriteCond %{HTTP_HOST} !^excluded-sub\.my-main-site\.com$ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

You'll have to have a play to get the login.php working. This link may help:

share|improve this answer
Is this gonna redirect all my subdomains? I ask because this line looks strange: "RewriteCond %{HTTP_HOST} ^ [OR]"! Maybe I din't make myself clear, I want all, like * redirect to... – Nicusor Dumbrava Mar 8 '12 at 0:56
I edited my answer above to add the catch all, hope that does it for you – Sol Mar 8 '12 at 4:49
Thank you I will test it, and get back to you, thanks :) – Nicusor Dumbrava Mar 8 '12 at 16:18
I don't want all my subdomains to redirect to the mainsite, I just want all the login pages to redirect to my mainsite login page... [ * => ] If you know WP has a mysite/wp-admin for every blog/site in a network/multisite installation... and I don't want to customize every login page for every blog, just the one in the mainsite :) ... your code doesn't work for me, I need to customize it when I'll understand .htaccess scripting. – Nicusor Dumbrava Mar 17 '12 at 17:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.