2010-11-06 38 views
0

我在我的博客这些URL如何删除的index.html的index.php htaccess的与

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

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

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

如果你想从一个HTML文件中删除.html扩展名:

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

或者看到这个帖子:

+0

谢谢我会试试看! – Maca 2010-11-07 09:34:35

+5

这将'/ example/file.php'翻译成'/ example/file'。问题是如何将'/ example/index.php'或'/ example/index.html'重定向到'/ example /'。 – 2012-03-16 16:00:48