Remove .html from URLs with a redirect

前端 未结 8 1571
一向
一向 2020-12-29 14:32

We have a website, unfortunately all the URLs have the .html suffix, its a Magento installation, Magento allows you to change this on the CMS, but again, unfort

8条回答
  •  时光说笑
    2020-12-29 14:56

    Try adding the following to the .htaccess file in the root directory of your site redirect URLs with .html extension and remove it.

    Options +FollowSymLinks -MultiViews
    DirectorySlash Off
    
    RewriteEngine On
    
    RewriteCond %{SCRIPT_FILENAME}/ -d
    RewriteCond %{SCRIPT_FILENAME}.html !-f
    RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
    
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^(.+)\.html$ /$1 [R=301,L]
    
    RewriteCond %{SCRIPT_FILENAME}.html -f
    RewriteRule [^/]$ %{REQUEST_URI}.html [QSA,L]
    

提交回复
热议问题