How can I send a user to a new location, only if the user have no URI? I am trying the follow, but it does not works... it always send me to /newlocation
rewrite ^/$ http://www.domain.com/newlocation permanent;
rewrite ^/(.*)$ http://www.domain.com/$1 permanent;
So basically, what I need is:
If the user writes on browser www.domain.org it sends to www.domain.com/newlocation If the user writes on browser www.domain.org/something it sends to www.domain.com/something
Thanks!
I'm not sure why your current approach isn't working. ^/$ should only match /. Maybe it's something else it the current config. Here's a server that should do what you want.
server {
server_name www.domain.org;
# Only match requests for /
location = / {
rewrite ^ http://www.domain.com/newlocation permanent;
}
# Match everything else
location / {
rewrite ^ http://www.domain.com$request_uri? permanent;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With