WordPress.org

Ready to get started?Download WordPress

Forums

One login for all blogs in a multisite! (16 posts)

  1. Nio
    Member
    Posted 2 years ago #

    I want all my blog login pages to be redirected to the main site login page.
    I don't understand .htaccess scripting, but it should do something like this:
    *.mysite.com/login.php => mysite.com/login.php

    Examples:
    site1.mysite.com/wp-login.php Redirected To mysite.com/wp-login.php
    site2.mysite.com/wp-login.php Redirected To mysite.com/wp-login.php
    xyzkw.mysite.com/wp-login.php Redirected To mysite.com/wp-login.php
    .......................
    Any future subdomain.mysite.com/wp-login.php - with no exceptions - will have to be redirected to mysite.com/wp-login.php

    Thanks!

  2. dgilmour
    Member
    Posted 2 years ago #

    This is a question about the syntax for Apache .htaccess redirect directives, so not really one for a WordPress forum.

    Given that you're asking it here, can I ask why you want to do this? Your Multisite system uses a shared set of usernames and passwords, and users log on to the Multisite system, not an individual blog. Where do you want them to end up once they've logged in? If they don't have any rights on the main site, this seems an odd thing to want to do.

  3. Nio
    Member
    Posted 2 years ago #

    I don't want to customize every login page for every blog, just the one in the main site :)

  4. dgilmour
    Member
    Posted 2 years ago #

    There are plugins that will handle that for you. Search for "wordpress plugin custom login page".

  5. Nio
    Member
    Posted 2 years ago #

    I already have a custom login page is here: mysite.com/wp-login.php, I don't need a plugin for that.

    I don't want that login page to be replicated... I don't want stupid duplicated content on all my child themes... I need one login page for all my sites/blogs... so when somebody try to login from any subdomain... like subdomain.mysite.com/wp-login.php to be redirected on mysite.com/wp-login.php.

    It that simple :)

  6. Doesn't really work that way. I mean, you could run a redirect to send everyone from NOT mysite.com... to mysite.com for logins, but that may cause issues with cookies.

    I do know that if you log in for one site, you're logged in for all, but sometimes I have to re-login on subdomains, so I wonder if there are cookie issues going on.

  7. Nio
    Member
    Posted 2 years ago #

    @ipstenu if you know how to make a redirect with .htaccess, please give me the script and I will try to see if I got any problem with cookies; as far as I know WordPress use same cookies on all the blogs/sites on a MultiSite installation.

    What do you mean: "redirect to send everyone from NOT mysite.com... to mysite.com"?
    I don't want to redirect from another domain. I use one domain with WordPress Multisite (subdomains) ... and on the main site (mysite.com) I use BuddyPress. All members that login on main site... have access and are logged in on all of my blogs/sites/subdomains ... no problem with that. I tested.

    I just want a simple redirect of all my login pages (of blogs/sites/subdomains) to one single login page (on main site)... the login page should look the same by using one custom login page that I can easily be customized when I need to... I really don't see what is the problem with this... now members already login from that login page, but some members will try to login from subdomains, especially if they know the site is build on WP platform... and I don't want them to see the "NOT SO CUSTOMIZED" login pages that themes offer by default :) ...

    Thanks you guys for taking the time with this :)

  8. dgilmour
    Member
    Posted 2 years ago #

    What do you mean: "redirect to send everyone from NOT mysite.com... to mysite.com"?

    Ipstenu doesn't mean redirect from another domain, I think, but redirect from a subsite to the main site.

  9. Right, I mean something like using a

    RewriteEngine on
    RewriteCond %{HTTP_HOST}   !^$
    RewriteCond %{HTTP_HOST}   !^example.com [NC]
    RewriteRule ^/wp-login.php(.*)         http://example.com/wp-login.php$1 [L,R=301]

    Which says 'If you're from *.example.com, then...' NOT example.com means just that. Anyone on the example.com server that isn't coming to wp-login.php ON example.com, but instead comes to foo.example.com, goes to example.com

    That said, I have no idea how well it'd work.

    The other option would be to look into how things like BuddyPress handle logins.

  10. Nio
    Member
    Posted 2 years ago #

    @Ipstenu, thank you, but it doesn't work.
    I search on internet for this and is so strange that I'm like the only one that wants a unified login page for a Multisite/BuddyPress site.

    This is my default .htaccess file

  11. Make a page on your main site and put a login form there. Use http://codex.wordpress.org/Function_Reference/wp_login_form for the code (which you'll put in your pagename.php file, not the source of the page).

    Then you just make that your login link.

    wp-login.php will still work (it has to, since other things rely on it), but you'll direct people to that page to login. You could even edit the buddybar to link there for login.

  12. Austin Passy
    Member
    Posted 2 years ago #

    Just wanted to touch base and ask a question.

    I've used a rewrite rule for login redirects on WordPress installs but noticed in a Multisite with subdomains that each site has a wp-login.php and the rewrite doesn't seem to work on main site let alone others.

    Better way to handle this?

    add_rewrite_rule( 'login/?$', 'wp-login.php', 'top' );
  13. Austin Passy
    Member
    Posted 2 years ago #

    Figured out my own answer!

    add_rewrite_rule( 'login/?$', 'index.php?login=true$matches[1]', 'top' );

    Then added a query variable login, and did a redirect on pre_get_posts

  14. Nio
    Member
    Posted 2 years ago #

    @Austin Passy
    I'm glad that my topic inspired you so much...:D maybe one day I'll find my own answer just like you did :)

  15. RonStrilaeff
    Member
    Posted 1 year ago #

    I'm glad this thread is not closed since I'd like to do something similar.

    The blogs on my multisite are not personal blogs, but photo galleries and links in different content areas (like categories I guess, but bigger with separate URLs). What I want is for anyone who registers on any site to be automatically registered for all sites and get a profile made for them on the main buddypress site and bbpress forum.

    But I'm not sure how to do it. Does buddypress have a way to handle that and somehow "know" that someone registered on a sub site?

    Nio, did you find an answer to your single login page for all sites question?

  16. Nio
    Member
    Posted 1 year ago #

    No, but somehow I resolved the "issue".
    I redirected the login pages to they respective homepage.
    Like this:
    mysite.com/wp-login.php Redirected To mysite.com/
    site1.mysite.com/wp-login.php Redirected To site1.mysite.com/

    I only have a login form on my main/root site, but that's OK for me.

    I'm still interested for a solution to my first statement for my feature projects.

Topic Closed

This topic has been closed to new replies.

About this Topic