WordPress redirect htaccess

I have a problem with my htaccess file in wordpress. I want to redirect users who come to /wp-login.php?action=register to another registration form with role parameter. Like this /wp-login.php?action=register&role=patient. So i wanna hide first url from users. I wrote this line in my htaccess.

RewriteRule ^wp-login.php?action=register$ /wp-login.php?action=register&role=patient [NC,L]

It’s located here in my file:

Read More
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /
RewriteRule ^wp-login.php?action=register$ /wp-login.php?action=register&role=patient [NC,L]
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

And i have no effect with that. What am i doing wrong here?

Related posts

Leave a Reply

2 comments

  1. You have to match for the query string in a RewriteCond:

    RewriteCond %{QUERY_STRING}  ^action=register$
    RewriteRule ^wp-login[.]php$ /wp-login.php?action=register&role=patient [R,NC,L]
    

    Edit: corrected my answer

  2. Another problem and solution involves htaccess:
    When you have your website at a host provider from which you obtain WordPress installation, it can occur that your WP is not in the root directory, but in a directory called WordPress-xxxx

    For instance: your website address is : http://website.com

    so your path is: http:/website.com/wordpres-xxx/file xxx
    However, most providers use in the background a redirect so it seems to your visitor goes directly to http://website.com

    For htaccess this is a problem. If you look in your WP directory you will find htaccess and a good change it has the right format. But, there is another htaccess on your root. Often you cannot change this one, because your provider blocks it for any modification for safety reasons.

    That is why your visitors cannot find your pages on your website (404) because that htaccess file in your root, did not change.

    You have to ask your provider to sync both htaccess files. the one in WP should be copied/ overwrite the one in your real root directory.

    that would solve the problem