我有一个关于重定向的问题,我想将 example.com/product-bag.html 重定向到 example.com/product-bag
我想重定向但不影响网站在 Google 中的关键字。
我的尝试
当我添加以下代码时:
rewrite ^/ \.html$ https://example.com permanent;
重新启动 Nginx 时,出现错误,提示我无法保存文件
我不确定这样做是否正确。谢谢!
您可以尝试在您的
nginx configuration
中使用给定的代码吗?它应该适合你。
server {
listen 80;
server_name example.com;
# Redirect from .html to desired URL.
rewrite ^/(.*)\.html$ /$1 permanent;
}