• Resolved carlla

    (@carlla)


    Twice I have to do it, in 2 blogs. Then I thought to do a tutorial to help someone else. I how it helps you too.

    1) Redirect with .htaccess
    the original .htaccess looks like that

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    so, after

    RewriteBase /

    add a new rule

    RewriteBase /
    RewriteRule ^login$ wp-login.php

    Now you can access the login page using these 2 urls (/login and /wp-login.php). So we need to hide the wp-login.php links in your blog.

    2) Change the links from wp-logins.php to /login
    in your functions.php (or someone plugin) add this filter

    add_filter('site_url',  'wplogin_filter', 10, 3);
    function wplogin_filter( $url, $path, $orig_scheme )
    {
     $old  = array( "/(wp-login\.php)/");
     $new  = array( "login");
     return preg_replace( $old, $new, $url, 1);
    }

    Now, every time wordpress call site_url(“wp-login.php?action=xxx”); this function will redirect to /login.

    3) Notes
    I think there are some few links to wp-login.php which wordpress make without use the filter ‘site_url’. So you need to look for ‘wp-login.php’ on /wp-include and /wp-admin and change it. You can use site_url(‘wp-login.php?[and the actions]’); instead the hard code link.

    I think there is other way, but it worked well for me.
    Any suggestion is very apreciated =)

    I am also looking for how to change the wp-admin to admin.

    I hope it can help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thanks!

    Great post, it worked like a charm. I’m running WP 3.0.1 with buddypress and one of the links that I had to chase down and change was in the admin bar. If anyone else needs to do this after making carlla’s changes just put the following code in your template’s functions.php file:

    function new_login_link(){
    	global $bp;
    	if ( is_user_logged_in() )
    		return false;
    	echo '<li class="bp-login no-arrow"><a href="' . $bp->root_domain . '/login?redirect_to=' . urlencode( $bp->root_domain ) . '">' . __( 'Log In', 'buddypress' ) . '</a></li>';
    	// Show "Sign Up" link if user registrations are allowed
    	if ( bp_get_signup_allowed() ) {
    		echo '<li class="bp-signup no-arrow"><a href="' . bp_get_signup_page(false) . '">' . __( 'Sign Up', 'buddypress' ) . '</a></li>';
    	}
    }
    remove_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu', 2 );
    add_action( 'bp_adminbar_menus', 'new_login_link', 2 );

    This will replace the function in the buddypress core adminbar file with a new function which swaps “login” for wp-login.

    adding the filter to site_url function seems not to work entirely for wp3.0.
    in detail: if i add the filter, the action of loginform on rootinstance/LOGIN works, but on subinstance/LOGIN the filter doesnt affect the action parameter of the loginform, making the form useless.

    here the produced tags:

    rootinstance/LOGIN:
    <form method=”post” action=”https://localhost/wordpress/login.php&#8221; id=”loginform” name=”loginform”>

    subinstance/LOGIN:
    <form method=”post” action=”https://localhost/wordpress/firstsubsite/wp-login.php” id=”loginform” name=”loginform”>

    how should i add the filter?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change from wp-login.php to login’ is closed to new replies.