【问题标题】:Spam and Old URLs Modification垃圾邮件和旧 URL 修改
【发布时间】:2013-11-03 07:54:53
【问题描述】:

这是Fake URLs created automaticly的引用。 https://stackoverflow.com/users/548225/anubhava

解决了这个问题。 错误或垃圾邮件创建了太多的 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>

【问题讨论】:

    标签: wordpress .htaccess mod-rewrite


    【解决方案1】:

    我相信你需要另外 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]
    

    确保这些是位于 RewriteEngine On 下方的前 3 条规则

    【讨论】:

    • 只剩下一件事,这是我的错误。我的类别类似于“latest-pakistani-anarkali-pishwas-frock-wear”而不是“category5”。
    • 我应该使用您给定的代码还是有什么方法可以选择我的每个类别
    • 重写规则 ^(latest-pakistani-anarkali-pishwas-frock-wear+/[^/]+/?).+$ /$1? [L,NC,R=301]
    • 哇,我是 stackoverflow.com 的新手,它对我来说非常好用。我一直在寻找这 3 周,@anubhava 在短短几分钟内就解决了它。
    • 不客气,请接受答案,这就是对 SO 表示感谢的方式:P
    猜你喜欢
    • 2011-06-14
    • 2013-01-05
    • 1970-01-01
    • 1970-01-01
    • 2011-07-12
    • 1970-01-01
    • 2011-01-24
    • 2013-10-13
    • 2014-06-04
    相关资源
    最近更新 更多