我刚从Drupal + Wordpress转移到完全用WordPress构建的站点.
我有一组图像,文件不再存在,需要尝试将所有图像保存在一个文件夹中(如果可能的话).我需要向http://www.domain.com/blog/wp-content/uploads/发送任何gif | png | jpg的请求到http://www.domain.com/wp-content/uploads.
如果有人能提供帮助将会受到赞赏 - 我的.htaccess不再是曾经的.提前致谢
use*_*736 11
如果您谷歌搜索"htaccess重定向",顶部链接是这样的:http:
//www.htaccessredirect.net/
如果您使用"301重定向目录"部分,则会获得以下代码:
//301 Redirect Entire Directory
RedirectMatch 301 /blog/wp-content/uploads/(.*) /wp-content/uploads/$1
Run Code Online (Sandbox Code Playgroud)
据我所知,目标域应该是绝对的,因此以下可能有效:
//301 Redirect Entire Directory
RedirectMatch 301 /blog/wp-content/uploads/(.*) http://www.domain.com/wp-content/uploads/$1
Run Code Online (Sandbox Code Playgroud)
请在您的 .htaccess 中尝试此规则:
RewriteEngine On
RewriteRule ^/blog/wp-content/uploads/(.+)\.(png|gif|jpg)$ wp-content/uploads/$1.$2 [QSA,L]
Run Code Online (Sandbox Code Playgroud)