Home  >  Q&A  >  body text

Nginx rewrites login address

The backend login address of my website is like this, www.example.com/login.php
But I want to hide the login address through Nginx and replace it with an uncommon login address, which becomes www.example .com/secretlogin.php. It also requires that access to login.php be prohibited.
My previous Nginx configuration was:

location ^~ /login.php {
    return 403;
}
location ^~ /secretlogin.php {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    rewrite ^/secretlogin.php /login.php break;
}

But when I finally visited www.example.com/secretlogin.php, a 404 appeared.
I don’t know what the correct configuration should be.

漂亮男人漂亮男人2714 days ago435

reply all(1)I'll reply

  • 阿神

    阿神2017-05-16 17:11:26

    rewrite ^/secretlogin.php.php /login.php break;
    More .php
    or just like this

    <?php include './login.php';?>

    reply
    0
  • Cancelreply