一个过时的Wordpress图像插件给我留下了4000 404个错误。
为了解决该问题,我想批处理301重定向数以千计的旧附件链接URL,以指向原始源图像文件:
出现404错误的旧网址如下所示:
我想将它们分别重定向到文件实际存在的wp-content / photos目录:
http://www.hongkonghustle.com/wp-content/photos/zombie_boy_tattoo_lady_gaga_rick_genest.jpg
从我的阅读中,我相信我应该更改我的htaccess文件并使用{QUERY_STRING}添加RewriteCond,但我不知道具体如何。
另外,相对于我当前的htaccess,我应该将这些更改放在哪里?
我当前的htaccess文件包括以下内容:
Options +Indexes
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^hongkonghustle\.com
RewriteRule ^(.*)$ http://www.hongkonghustle.com/$1 [R=permanent,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.hongkonghustle.com/$1/ [L,R=301]
RewriteEngine On
RewriteBase /
<Files wp-config.php>
Deny from all
</Files>
<Files wp-config.php>
Deny from all
</Files>
Options +Indexes
IndexOptions -FancyIndexing
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
再次感谢Anubhava!你已经很近了!
现在转到/ wp-content / photos /目录,但是URL仍然不正确:
hongkonghustle.com/wp-content/photos/&/?pagename=album&%253fpp_album=main&pp_cat=default&pp_image=zombie_boy_tattoo_lady_gaga_rick_genest.jpg
我们需要的最终URL为:
hongkonghustle.com/wp-content/photos/zombie_boy_tattoo_lady_gaga_rick_genest.jpg
因此,hongkonghustle.com / wp-content / photos / IMAGE_FILENAME.JPG
我认为这几乎解决了!如果您对如何完成此操作有任何想法,请及时更新。真诚的感谢!
我最终在htaccess中进行了301重定向,如下所示:
Options +Indexes
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} ^pagename=album&\??pp_album=main&pp_cat=default&pp_image=(.*)$
RewriteRule .* /wp-content/photos/%1? [L,R=301]
RewriteCond %{HTTP_HOST} ^hongkonghustle\.com
RewriteRule ^(.*)$ http://www.hongkonghustle.com/$1 [R=permanent,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.hongkonghustle.com/$1/ [L,R=301]
RewriteEngine On
RewriteBase /
<Files wp-config.php>
Deny from all
</Files>
<Files wp-config.php>
Deny from all
</Files>
Options +Indexes
IndexOptions -FancyIndexing
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句