I'm 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.
EDIT: It's worth mentioning that I only want example.com to redirect to example.com/test. I don't want example.com/something to have /test in the url.
What is the correct way to do this?
This is a snippet of my current nginx.conf:
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;
}
}
serverblocks with the sameserver_name? NGINX will only process the first one it comes to – sam Jun 24 '11 at 7:56server_nameshould only occur in ONE server block. I.E. example.com can only be in one server block regardless of how many other domains you have – sam Jun 24 '11 at 8:01