Permanent redirect after removing html extension in htaccess

后端 未结 1 490
陌清茗
陌清茗 2021-01-21 11:00

I have these htaccess rules to remove html extension from urls:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME         


        
1条回答
  •  梦毁少年i
    2021-01-21 11:34

    Just add the little snippet at the end which indicates it is a 301 redirect.

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.html -f
    RewriteRule ^(.*)$ $1.html [R=301,L]
    

    0 讨论(0)
提交回复
热议问题