2013-08-30 103 views
0

我想編輯的WordPress 3.5 .htaccess文件來定義一些URL重定向規則,例如:WordPress的:htaccess的重定向URL

Redirect http://localhost/my_site/blog/cat/hello-world to http://localhost/my_site/cat/hello-world 

我試圖

Redirect 301 /localhost/my_site/blog/cat/hello-world/ http://localhost/my_site/hello-world/ 

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /my_site/ 

Redirect 301 http://localhost/my_site/blog/cat/hello-world/ http://localhost/my_site/cat/hello-world/ 

RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /my_site/index.php [L] 
</IfModule> 

但瀏覽器說

Page Not Found

這有點令人尷尬,不是嗎?

任何想法..我該怎麼做..?

回答

1

你不想使用Redirect與mod_rewrite一起使用,只需使用mod_rewrite。將Redirect替換爲:

RewriteRule ^my_site/blog/cat/hello-world/ /my_site/cat/hello-world/ [L,R=301]