【发布时间】: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
我只是想问一下,如何使用 htaccess 为我网站的每个 url 添加 html 后缀?
这样的网址:
www.mysite.com/index.php?hello/world
应该变成
www.mysite.com/index.php?hello/world.html
【问题讨论】:
标签: php apache .htaccess httpd.conf
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1\.html [R=301,L]
【讨论】:
另一种方法是打开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 了解更多选项信息。
【讨论】: