【发布时间】:2015-03-20 21:03:43
【问题描述】:
我正在尝试通过编辑 web root(public_html) 目录下的 .htaccess 文件从我的网站的 url 中删除 .html 扩展名。我的服务器是bluehost。
问题是我已经在 .htaccess 文件中有以前的设置,用于将主域重定向到子目录。
脚本如下。还有我在网上找到的用于从 url 隐藏扩展名的脚本。(该脚本不起作用)如果有人能帮助我解决这个问题,那就太好了。谢谢。
# Use PHP5.4 Single php.ini as default
AddHandler application/x-httpd-php54s .php
# BlueHost.com
# .htaccess main domain to subdirectory redirect
# Do not change this line.
RewriteEngine on
# Change example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?qinglish.ca$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/qinglish_ca/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /qinglish_ca/$1
# Change example.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?qinglish.ca$
RewriteRule ^(/)?$ qinglish_ca/index.html [L]
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
【问题讨论】:
-
究竟是什么不工作?
-
.html 扩展名仍然显示