Welcome! Log In Create A New Profile

Advanced

Nginx redirect domain and sub-domain without www

February 19, 2013 04:54PM
Hello,

for saas web application project I need to redirect subdomains to a specific directory (app-saas /) without the www.

The domain name must also be without redirecting to the www root.


Ex.
www.domain.tdl to domain.tdl
www.sub.domain.tdl to sub.domain.tdl

www
|-- index.php (domain.tdl, without www)
`-- app-saas/ (sub.domain.tdl, without www)


So I did this but if it does not work with: www.sub.domain.tdl

server {
listen 80;
server_name ~^www\.(\w+)\.domain\.com$
root /var/www/app-saas;

location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
}

server {
listen 80;
server_name domain.com;
root /var/www;

location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
}


f possible I would like to assemble her two redirect rules in a single parenthesis "server {...}" to apply to all common filters (header expire, deny, Hotlink, etc.)

thank you for your help, cordially.
SubjectAuthorPosted

Nginx redirect domain and sub-domain without www

la_chouetteFebruary 19, 2013 04:54PM

Re: Nginx redirect domain and sub-domain without www

Francis DalyFebruary 19, 2013 06:22PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 73
Record Number of Users: 2 on November 23, 2014
Record Number of Guests: 377 on November 23, 2014
Powered by nginx    Powered by FreeBSD    PHP Powered    Powered by Percona     ipv6 ready