nginx redirect TLD to TLD with virtual folder (example.com => example.com/test)
Posted
by
Amund
on Server Fault
See other posts from Server Fault
or by Amund
Published on 2011-06-24T06:55:32Z
Indexed on
2011/06/24
8:24 UTC
Read the original article
Hit count: 338
Im running nginx and in the config file I need to always have the domain example.com redirect to example.com/test. I tried various methods for achieving this but I always got a redirect error.
What is the correct way to do this?
nginx.conf snippet:
server {
server_name example.com www.example.com;
location / {
rewrite ^.+ /test permanent;
}
}
server {
listen 80;
server_name www.example.com example.com;
location / {
root /var/www/apps/example/current/public;
passenger_enabled on;
rails_env production;
}
}
Thanks!
© Server Fault or respective owner