【问题标题】:How to Add URL Suffix如何添加 URL 后缀
【发布时间】:2010-12-16 04:35:58
【问题描述】:

我只是想问一下,如何使用 htaccess 为我网站的每个 url 添加 html 后缀?

这样的网址:

www.mysite.com/index.php?hello/world

应该变成

www.mysite.com/index.php?hello/world.html

【问题讨论】:

    标签: php apache .htaccess httpd.conf


    【解决方案1】:
      RewriteEngine On
    
      RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
    
      RewriteRule ^(.*)$ http://www.mydomain.com/$1\.html [R=301,L] 
    

    【讨论】:

      【解决方案2】:

      另一种方法是打开MultiViews。只需将以下行添加到目录(或 httpd.conf)中的 .htaccess 文件中。请注意,Options All 不会开启 MultiViews,您需要明确开启它。

      Options +MultiViews
      

      请参阅 http://httpd.apache.org/docs/2.0/en/content-negotiation.html 中的 MultiViews 部分了解更多信息,了解更多信息,http://httpd.apache.org/docs/2.0/en/mod/core.html#options 了解更多选项信息。

      【讨论】:

        猜你喜欢
        • 2016-06-09
        • 2018-11-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-03-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多