如何使用htaccess删除index.html index.php

时间:2010-11-06 08:57:39

标签: .htaccess mod-rewrite

我的博客中有这些网址

http://myblog.com/news/post1/index.php
http://myblog.com/updates/post3/index.html
http://myblog.com/index.html
http://myblog.com/blog/post4/index.php

如何设置.htaccess以便所有网址都以“/”

结尾
http://myblog.com/news/post1/
http://myblog.com/updates/post3/
http://myblog.com/
http://myblog.com/blog/post4/

提前致谢!

1 个答案:

答案 0 :(得分:1)

从PHP文件中删除.php扩展名:

Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L] 

如果要从html文件中删除.html扩展名:

RewriteRule ^([^\.]+)$ $1.html [NC,L] 

或者看到这篇文章: