我將約38個網站從Joomla移動到WordPress。.htaccess + wordpress,多目錄重定向
我想保持相同的鏈接結構,因爲SEO。不幸的是,最後一名開發者對他們鏈接的構造方式不在意,所以我有一些古怪的要求來完成。
即有時他們的博客是index.php/blog-4,同時index.php/blog和index.php/blog-5。
在WordPress,我做了永久鏈接是
的index.php /博客-5 /%postname%
我以前從來沒有編輯的.htaccess,但我想要做的是重定向任何去
/博客/ * - > /博客-5/*
/博客-4/* - > /博客-5/*
我會怎麼寫完成這個?
編輯
我在實施邁克爾的回答麻煩。這是我的.htaccess的外觀。我試圖把它放在內外。
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{REQUEST_URI} !^/blog-5
RewriteRule ^blog(-.+)?/(.*) blog-5/$2 [L,R=301]
</IfModule>
# END WordPress
喜邁克爾,爲快速解答感謝。這是有道理的。我嘗試添加這個,雖然我沒有看到重定向發生。這可能是因爲我在.htaccess文件中編寫它的方式。我用htaccess文件更新了這個問題。思考非常感謝 –
@StepanParunashvili對不起,我錯過了你的評論,不知道爲什麼我沒有看到通知。它看起來像'重寫規則。/index.php'可能首先被匹配。註釋掉這條線來測試新規則。可能您需要將其添加回_last_規則。 –
@StepanParunashvili我看你打上再次接受了,所以我希望摸索出適合你。 –