【问题标题】:Remove or redirect wrong indexed urls from my website?从我的网站中删除或重定向错误的索引网址?
【发布时间】:2013-11-08 00:13:10
【问题描述】:

这与我的其他问题Spam and Old URLs ModificationFake URLs created automaticly 的关系。 有人能告诉我为什么要创建它们吗?我想重定向到下面的网址。我想从我的域名中删除多余的字符串或垃圾邮件。我更喜欢.htaccess。我正在使用 wordpress。

deemasfashion.com/ **cgi-sys/defaultwebpage.cgi**
deemasfashion.com/ page/38/wpmp_switcher
deemasfashion.com/ ?2fou_com
deemasfashion.com/ **?iapolo_com**
deemasfashion.com/ ?dur=2016 
deemasfashion.com/ **?dur=375**
deemasfashion.com/ ?file
deemasfashion.com/ ?option=com_content&view=frontpage&itemid=1
deemasfashion.com/ ?option=com_content&view=category&id=34:latest-tech- news&itemid=60
deemasfashion.com/ ?www.web3389.com
deemasfashion.com/ ?wpmp_switcher=desktop
deemasfashion.com/ ?option=com_content&view=category&id=34%3Alatest-tech-news&Itemid=60

我在 Document_root 代码中的.htaccess 代码如下。

<IfModule mod_rewrite.c>
RewriteEngine On

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

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

# function.session-start not working
# RewriteRule ^(latest-pakistani-anarkali-pishwas-frock-wear/[^/]+/?).+$ /$1? [L,NC,R=301]
# code by anubhava

# BEGIN WordPress
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]
# END WordPress
</IfModule>

【问题讨论】:

  • @anubhava 你也能回答这个问题吗?我试图修改给定的规则,但它们对我来说真的很难

标签: regex wordpress apache .htaccess mod-rewrite


【解决方案1】:

在任何其他规则之前尝试这些规则和指令:

# forward 404 to home page
ErrorDocument 404 /

RewriteEngine On

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

RewriteCond %{QUERY_STRING} ^option=.+$ [NC,OR]
RewriteCond %{QUERY_STRING} ^[^=]+$
RewriteRule ^$ /? [L,NC,R=301]

【讨论】:

  • 你真是个天才。非常感谢你,排灯节快乐@anubhava。一切都解决了,但只有一个例外。 deemasfashion.com/?p=368 也正在重定向到主页。我已经多次使用这种类型的链接。帖子 ID 可以更改。
  • 谢谢,也祝您排灯节快乐。我现在在手机上,一到我的电脑就会给你建议一个出路。
  • 感谢我将您的旧代码和新代码合并。现在这适用于 .com 和 .com/page/。并且无需为 p=368 添加例外。
  • 但是为什么这些 URL 会被搜索引擎创建和索引
  • 这些网址可能已被某些外部网站/实用程序编入索引,或者可能是您的旧网址。
猜你喜欢
  • 1970-01-01
  • 2016-09-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-25
  • 1970-01-01
  • 2015-09-27
  • 2010-11-17
相关资源
最近更新 更多