2013-05-01 126 views
0

我想將我的網站的永久鏈接結構從/%postname%/更改爲/%category%/%post_id%/%postname%/,並將舊鏈接重定向到新結構目前得到404的)。我嘗試了幾個不同的重定向插件(重定向,301簡單插件),我無法讓它們工作。重定向Wordpress htaccess中的永久鏈接

有人可以告訴我放入htaccess文件的規則嗎?

謝謝!

回答

3

如果你知道一個給定的postname明確的類別和POST_ID,那麼你可以單獨創建重定向:

Redirect 301 /example-post-name-to-redirect/ /example-category/1234/example-post-name-to-redirect/ 

或使用mod_rewrite(注意,這些規則前必須你的WordPress規則:

RewriteRule ^example-post-name-to-redirect/$ /example-category/1234/example-post-name-to-redirect/ [L,R=301] 

但更好的解決辦法只是使用WordPress來爲你做這個,你有沒有試過?UrbanGiraffe Redirection pluginScott Yang's Permalink Redirect WordPress Plugin,或Yoast's Permalink Redirect WordPress Plugin

+0

嗨,我的網站有1000的職位,所以這樣做手動爲每個職位絕對不會是理想的。 我嘗試過UrbanGiraffe one(沒有運氣),但我會給其他兩個嘗試以及。 – ziirahdane 2013-05-01 17:42:46

+0

嗨,再次,Yoast的插件工作魅力(其他沒有)。謝謝! – ziirahdane 2013-05-01 18:09:34