Welcome! Log In Create A New Profile

Advanced

Nginx. Wild card Alias location. Is it possible?

Posted by suchislife801 
Nginx. Wild card Alias location. Is it possible?
April 14, 2011 03:02PM
Dear Experts,

I have been trying to figure out what exactly am I missing to get this to work 100%.

**Internal Directory Structure:**

www
www/profiles
www/profiles/random_user_directory_here
www/profiles/random_user_directory_here/index.php

**Desired External Request:**

http://mysite.com/random_user_directory_here

My Question:

Every time a new user on my site creates an account, an internal directory is created with their username.

This directory has an index.php file.

Whenever the user goes to URL http://mysite.com/random_user_directory_here, I Want the server to display the contents of index.php for this user.

My Problem:

The following script works only if the user types http://mysite.com/random_user_directory_here/index.php BUT it does not work if they type http://mysite.com/random_user_directory_here

location ~ ^/([^/]+)/([^/?]+)$ {

alias www/profiles/$1/$2;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME www/profiles/$1/$2$fastcgi_script_name;
include fastcgi_params;

}

Can anyone please explain what I'm missing? I tried just about everything I know but I can't figure it out..

Please feel free to correct my regex if there's anything wrong or extra in it.

Thanks a lot for any help.
Re: Nginx. Wild card Alias location. Is it possible?
April 14, 2011 03:38PM
This seems to work. All I need to find out is how to turn random_user_directory_here_123 into regex.

location /random_user_directory_here_123 {
root www/profiles;
index index.php;
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 309
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready