【问题标题】:Removing .html file extension from URL with an .htaccess file使用 .htaccess 文件从 URL 中删除 .html 文件扩展名
【发布时间】:2015-12-15 09:57:16
【问题描述】:

我已经在我的 .htaccess 文件中尝试了许多不同的 sn-ps,以便从 URL 中删除 .html 文件扩展名。到目前为止,我在这里阅读了一些其他没有用的答案,研究了一些个人博客,甚至发现了一些在 Chris Coyier 的 CSS Tricks 上不起作用的技巧。

这是我尝试过的几个:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

还有:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html

感谢我能得到的任何帮助。

【问题讨论】:

    标签: html .htaccess mod-rewrite


    【解决方案1】:
    RewriteEngine on 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME}\.html -f 
    RewriteRule ^(.*)$ $1.html
    

    【讨论】:

      猜你喜欢
      • 2016-12-28
      • 2012-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-04
      • 2015-08-02
      相关资源
      最近更新 更多