nginx redirect TLD to TLD with virtual folder (example.com => example.com/test)
- by Amund
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!