当使用以.html结尾的URL访问页面时,我希望该URL更改为无扩展名,并且报告301永久重定向。我遇到了严重的困难。在阅读了大量的文档和教程,并搜索了几个小时的Stack Overflow之后,我得到的最接近的结果是相反的(没有添加扩展名的URL),代码如下:
<Location />
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.html$
RewriteRule ^(.*)$ https://%{HTTP:Host}%{REQUEST_URI}.html [L,R=permanent]
</Location>
https://stackoverflow.com/questions/51690012
复制相似问题