Question
301 redirect nginx
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.
×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.
×
rewrite ^/category/something/(.*)$ http://site.com/something/$1 redirect;
service nginx restart
That’s for a 302 redirect. For a 301, use permanent
not redirect
.
Hi admin
I want change old a URL https://www.bandatnendongnai.vn/du-an/
New URL https://www.bandatnendongnai.vn/category/du-an/
I using nginx. Thank you so much
location /du-an {
rewrite ^/du-an(.*) https://$server_name/category/du-an/$1 permanent;
}
service nginx restart
server {
listen 80;
server_name www.bandatnendongnai.vn bandatnendongnai.vn 202.182.98.49;
rewrite ^(.*) https://www.bandatnendongnai.vn$1 permanent;
rewrite ^/du-an(.*) https://$server_name/category/du-an/$1 permanent;
}
server {
listen 443 ssl http2;
server_name bandatnendongnai.vn;
return 301 https://www.bandatnendongnai.vn$request_uri;
rewrite ^/du-an(.*) https://$server_name/category/du-an/$1 permanent;
ssl_certificate /etc/nginx/paidssl/www.bandatnendongnai.vn/www.bandatnendongnai.vn.crt;
ssl_certificate_key /etc/nginx/paidssl/www.bandatnendongnai.vn/www.bandatnendongnai.vn.key;
and then service nginx restart
Check nginx
nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Please help me. Thank you so much
Thanks work fine for me!