2013-12-09 44 views
1

我已將網站從joomla轉移到wordpress。最老的鏈接已被改得很好,但我得到一些奇怪的404使用正則表達式替換/重定向到.htaccess

我想什麼是能夠給這個重定向:

http://www.pcsteps.gr/component/content/article?id=575:how-to-guide-wireless-network-security

爲了這個:http://www.pcsteps.gr/575-how-to-guide-wireless-network-security

這是我已經使用.htaccess文件內的代碼:

RewriteRule ^component/content/(.+)$ pcsteps.gr/$1 [R=301,L] 

此代碼除去/部件/ content /部分URL,但我留下了「article?id = 575:how-to-guide-wireless-network-security」

如何更改代碼以刪除「article?id =「,保留數字並用」 - 「替換」:「?

+0

那你嘗試成功刪除「/組件/內容/」爲什麼不會刪除它的休息嗎? – OGHaza

+0

RewriteRule^component/content /(.+)$ http://www.pcsteps.gr/$1 [R = 301,L]會刪除它們,但我會留下「article?id = 575:how-指導無線網絡安全「 –

回答

1

把這個代碼在你DOCUMENT_ROOT/.htaccess文件:

RewriteEngine On 

RewriteCond %{QUERY_STRING} (?:^|&)id=([0-9]+):([^&]+) 
RewriteRule ^component/content/article/?$ /%1-%2? [L,NC,R=301] 
+0

對不起,它不起作用。 –

+0

我錯過了'文章'部分。現在修復它,你可以請嘗試。 – anubhava

+0

現在它刪除組件/內容/文章和id =,但它並不代替:with - 我得到http://www.pcsteps.gr/575:how-to-guide-wireless-網絡安全 –