2010-12-14 27 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