I have one problem about the redirecting I want to make redirect to example.com/product-bag.html to example.com/product-bag
I want to redirect but not affect the website's keywords in Google.
What I Try
when I add the code below:
rewrite ^/ \.html$ https://example.com permanent;
When restarting Nginx, I get an error saying I can't save the file
I'm not sure if that's the right thing to do or not. Thank you!
Could you please try to use the given code in your nginx configuration
. It should works for you.
server {
listen 80;
server_name example.com;
# Redirect from .html to desired URL.
rewrite ^/(.*)\.html$ /$1 permanent;
}