1

这是参考自动创建的假网址。这已由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>
4

1 回答 1

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

于 2013-10-24T14:36:20.197 回答