httpd.conf命令为.htaccess

时间:2012-01-04 22:46:41

标签: .htaccess mod-rewrite filenames httpd.conf

我使用httpd.conf和mod_rewrite从网页中删除文件扩展名....

我在httpd.conf中使用的代码是

    <IfModule mod_rewrite.c>
       Options +FollowSymLinks
       Options +Indexes
       RewriteEngine On
       RewriteCond %{SCRIPT_FILENAME} !-d
       RewriteRule ^([^\.]+)$ $1.html [NC,L]
    </IfModule>

这对我的外部服务器上的.htaccess文件不起作用,我无法访问httpd.conf文件....

如何更改命令的任何想法,以便我可以使用.htaccess删除网址中的所有 .html ........

提前感谢:D

1 个答案:

答案 0 :(得分:0)

在.htaccess文件中尝试以下内容

Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /

#if an html version of this file exists
RewriteCond %{REQUEST_FILENAME}\.html -f [NC]
#then server it
RewriteRule . %{REQUEST_FILENAME}.html [NC,L]