Question
Correct way to write 301 redirect?
My question is in regards to the correct way to write a 301 redirect from requests to our old site URLs. When we go live, we need the following redirect:
(.*)mydomain.com/index.php(.*) —> https://mydomain.com/home
In other words, any request that starts with:
- http://mydomain.com/index.php
- http://www.mydomain.com/index.php
- https://mydomain.com/index.php
- https://www.mydomain.com/index.php
should be redirected to https://mydomain.com/home.
My idea for how to do this would be to put the following line in our server block:
server {
. . .
server_name mydomain.com;
rewrite ^/index.php/(.*)$ https://mydomain.com/home permanent;
. . .
}
Is this correct? Thanks!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×