1

Please, how can I make this simple operation in Nginx:

I wish that every requests for uris like: http://example.com/adm or: http://example.com/adm Goes to the wordpress login page: wordpress/wp-login.php (The wordpress installation is inside the folder "wordpress").

I've tried:

location /adm/ { alias wordpress/wp-login.php; }
location /adm { alias wordpress/wp-login.php; }

and:

rewrite ^/adm$ wordpress/wp-login.php;

But with no success... The worse here is that some rules, like "rewrite /adm wordpress/wp-login.php;" (that does work!), auto redirects some requests, once the user is logged in, to the default wordpress admin page... And I do not know why...

Just in case someone asks, this is my serve conf. file:

server {
    server_name www.example.com;
    rewrite ^ http://example.com$request_uri? permanent;
}

server {
    server_name example.com;

    access_log /var/log/nginx/example.com.access;
    error_log /var/log/nginx/example.com.error;

    root /var/www/example.com;

    index index.htm index.php;

    location / {try_files $uri /wp$uri/ /wordpress/index.php$args;}

    location ~ .php$ {
        try_files $uri =404;
        #fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }

    location = /favicon.ico {log_not_found off;access_log off;}
    location = /robots.txt {allow all;log_not_found off;access_log off;}
    location ~ /\. {deny all;access_log off;log_not_found off;  }
}

Thanks.

2

I needed the same thing but the answer above looked a bit weird to me. For anyone else looking for a solution to this. I ended up using the following:

location ~* /login/ {
    rewrite ^/login/(.*)? /wp-admin/$1;
}
1

Folks at Nginx Forum helped me to find a solution for that: http://forum.nginx.org/read.php?2,202235,202475#msg-202475

This is what they came up with:

location = /adm/ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME /var/www/example.com/wordpress/wp-login.php
    include /etc/nginx/fastcgi_params;
}

location = /adm {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME /var/www/example.com/wordpress/wp-login.php
    include /etc/nginx/fastcgi_params;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.