Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to rewrite /wp-login.php?action=register to /register, but only if it's a GET request.

Here's what I have so far, while it doesn't error it just doesn't do anything..

location /wp-login.php {
    if ( $request_method = GET ) {
        set $login_post_req "herp";

    if ( $args ~ ^action=(register) ) {
        set $login_post_req "${login_post_req}derp";

    if ( $login_post_req = "herpderp" ) {
        rewrite / /register permanent;

Thanks :)

share|improve this question

try this:

    if ( $login_post_req = "herpderp" ) {
    rewrite /wp-login.php /register permanent;

maybe this:

rewrite /wp-login.php /register? permanent;

to avoid /register/?action=register

share|improve this answer
I'd tried that previously and it doesn't seem to make a difference.Thanks though. – James White Mar 21 '12 at 20:12
Sorry ... dont have access to my ngninx box right now, will work on it tonight. On the surface it doesnt seem that hard to make it work! – Rostol Mar 21 '12 at 22:34
Thanks man. I tried moving it inside my main location / block as well like so but the fundamental problem seems to be I can't even get a basic rewrite from wp-login.php to /register working. I've tried just rewrite ^(/wp-login.php) /register permanent; on it's own and still no joy :/ – James White Mar 21 '12 at 22:38

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.