Simple URI redirection / alias in Nginx…

atipico nginx-forum at nginx.us
Mon May 30 17:40:09 MSD 2011


Please, how can I make this simple operation:

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...

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;	}
	}

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,202235,202235#msg-202235




More information about the nginx mailing list