2013-10-24 78 views
1

這是與Fake URLs created automaticly的參考。這是通過https://stackoverflow.com/users/548225/anubhava

解決。 錯誤或垃圾郵件太多的URL已創建像下面,但現在我想重定向到他們各自的帖子頁的URL。垃圾郵件和舊URL的修改

我寧願.htaccess。請幫助

abc.com/wp-admin/post.php?post=4051&action=edit 
**Redirect to** 
abc.com/?p=4051 

abc.com/page/56/?option=com_content&view=article&id=94&Itemid=2 
**Redirect to** 
abc.com/page/56/ 

abc.com/category5/post-about-fashion/function.include 
**Redirect to** 
abc.com/category5/post-about-fashion/ 

我使用WordPress的。我的固定鏈接是/%category%/%postname%/。我htaccess的代碼如下...

<IfModule mod_rewrite.c> 
RewriteEngine On 

# code by anubhava 
RewriteCond %{QUERY_STRING} ^.+$ 
RewriteRule ^(page/[0-9]+/).*$ /$1? [L,NC,R=301] 
# code by anubhava 

RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
RewriteCond %{HTTP_HOST} ^www\.deemasfashion\.com$ 
RewriteRule ^deemasfashion\.com/?(.*)$ http://deemasfashion.com/$1 [R=301,L] 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/ 
RewriteRule ^index\.html$ http://deemasfashion.com/ [R=301,L] 
RewriteRule ^index\.htm$ http://deemasfashion.com/ [R=301,L] 
</IfModule> 

回答

2

我相信你需要2個額外的規則:

RewriteCond %{QUERY_STRING} ^.+$ 
RewriteRule ^(page/[0-9]+/?).*$ /$1? [L,NC,R=301] 

RewriteRule ^(category[0-9]+/[^/]+/?).+$ /$1? [L,NC,R=301] 

RewriteCond %{QUERY_STRING} (?:^|&)post=([^&]+) [NC] 
RewriteRule ^wp-admin/post\.php$ /?p=%1 [L,NC,R=301] 

確保這些都是前3名規則略低於RewriteEngine On

+1

+1爲*榮譽獎*由OP給出:) –

+0

非常感謝。我非常感謝你的幫助。 –

+0

只剩下一件事是我的錯誤。我的類別就像「最新 - 巴基斯坦 - anarkali-pishwas-frock-wear」而不是「category5」。 –