Redirect parameters .htaccess [closed]

-2

I would like to know how to redirect a url with parameters in .htaccess . I have a URL that can receive several parameters and I want to redirect it to another page with these parameters.

The page is wp-login.php , I have to redirect to the /login/ page. But I need to redirect all parameters, not just the page. ex:

http://site.com/wp-login.php?para=ola
http://site.com/login?para=ola

http://site.com/wp-login.php
http://site.com/login



RewriteRule ^/wp-login.php$ /login [QSA,L]
    
asked by anonymous 28.04.2016 / 02:39

2 answers

1

What you want is redirect yourself, which is different from rewriting, the way you did the .htaccess it only serves when you access:

http://exemplo/wp-login.php?teste=1

Will display the content of:

/wp-login.php?teste=1

For same redirects, where you will change the URL in the browser, you need to use the flag R= as per the documentation link

Another thing to regex sometimes has to escape some characters like . and - , also do not start with / , you may also have forgotten RewriteEngine On , it should look like this:

RewriteEngine On
RewriteRule ^wp\-login\.php$ login [QSA,L,R=302]

If /login is a folder do so to avoid more than one redirect:

RewriteEngine On
RewriteRule ^wp\-login\.php$ login/ [QSA,L,R=302]

I tested it here and it worked with GET.

    
28.04.2016 / 16:58
0

The solution found by me that worked on wordpress was the use of native functions. because .htaccess did not work:

add_action('init','custom_login');

function custom_login(){
    global $pagenow;
    if( 'wp-login.php' == $pagenow ) {
        wp_redirect('login');
        exit();
    }
}
    
28.04.2016 / 19:44