Welcome! Log In Create A New Profile

Advanced

Redirect subdomain to different folder

Posted by DatWarrior 
Redirect subdomain to different folder
February 11, 2012 10:40AM
Greetings, NGINX users!

I want to redirect any requests from my subdomain to another path then the main domain.

For example; A user enters foo.bar.com and sees files in /var/www2.

A user who access bar.com sees files in /var/www.

Thanks in advantage.
Re: Redirect subdomain to different folder
February 11, 2012 10:43AM
Here is my config:
# You may add here your
# server {
# ...
# }
# statements for each of your virtual hosts

server {

listen 80; ## listen for ipv4
listen [::]:80 default ipv6only=on; ## listen for ipv6
access_log /var/log/nginx/bar.com.access.log;

rewrite ^(.*) https://bar.com$1 permanent;

location / {
root /var/www;
index index.html index.htm;
}
}
server {
listen 443;

ssl on;
ssl_certificate /root/ssl/ssl.crt;
ssl_certificate_key /root/ssl/ssl.key;

location / {
root /var/www;
index index.html index.htm;
}
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 206
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready