2010-12-14 85 views
0

我正在尝试使用mod_rewrite清理我的URL。使用mod_rewrite清理URL

在我的网址,我有:

http://blog.com/cat/post1/index.html 
http://blog.com/cat/post2/index.html 
http://blog.com/cat/post3/index.html 
etc.... 

的.htaccess

RewriteEngine on 
RewriteCond %{THE_REQUEST} ^GET\ /.*/index\.(php|html)\ HTTP 
RewriteRule (.*)index\.(php|html)$ /$1 [R=301,L] 

当我进入我上面提到的网址获得:

http://blog.com/post1/ 

但我想:

http://blog.com/cat/post1/ 

我在这里做错了什么?

回答

1
RewriteEngine on 
RewriteCond %{THE_REQUEST} ^GET\ /.*/index\.(php|html)\ HTTP 
RewriteRule (.*) http://blog.com/cat/$1 [R=301, L] 
+0

没有和我一起工作。它仍然重定向到“http://blog.com/post1/”这是404 – Maca 2010-12-14 07:16:21

+0

编辑请求检查 – 2010-12-14 07:57:54

+0

其实我有我想改变的多个URL(我编辑了文档)。 http://blog.com/cat/post1/index.html,http://blog.com/cat/post2/index.html等... – Maca 2010-12-14 08:02:39