Rewriting URLs with Apache HTTPD can be pretty ugly. With Nginx it is a breeze. Take a look to this example:
server { listen 80; server_name my_old_domain.com; rewrite ^/(.*) https://www.my_new_domain.com/$1 permanent; }
This will not just redirect your old URL to your new URL. It passes all the parameter to your new URL, too. If you are migrating a Web Application to new URL, this what you want. All old bookmarked URL are still working with this.
There is another (and probably a better) way to do the same…
server {
server_name your_old_domain.com;
return 301 $scheme://your_new_domain.com$request_uri;
}
The advantage here is the 301 that may be good for SEO. 🙂
Yes. I guess that’s better. Thank you very much for the hint.