I need help to write a regex to redirect a URL path from:
http://mydomain.com/files/2012/10/image_4-1.png
to:
http://mydomain.com/wp-content/blogs.dir/5/files/2012/10/image_4-1.png
... the wp-content/blogs.dir/5
(it static) needs to be added.
Just can't figure it out... Can anyone help with the regular expression?
Enable mod_rewrite and .htaccess through httpd.conf
and then put this code in your .htaccess
under DOCUMENT_ROOT
directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^(files/2012/10/image_4-1\.png)$ wp-content/blogs.dir/5/$1 [L,R=302,NC]
PS: If you want to add wp-content/blogs.dir/5
before every path then use this rule:
RewriteRule (?!^wp-content/blogs.dir/5/)^(.*)$ wp-content/blogs.dir/5/$1 [L,R=302,NC]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.