Reputation: 986
My hosted images are linked in other websites , so now i want redirect those link to my site.
my images link look like this
http://example.com/uploads/images/September2014//iphone-6.gif
(all image types jpg,gif,png etc)
sepetember2014/ is dynamic text that will change every month (monthname(alphabets)Year(in digits))plus extra / on its end.
now i want above url redirect to
http://example.com/media/iphone-6
i try following but didint work
RewriteCond %{HTTP_REFERER} !example.com
RewriteRule ^\.jpg $1\.html [R=301,L
my site htacess look like this after using anubhava answer
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
RewriteCond %{HTTP_REFERER} !example\.com$
RewriteRule ^uploads/images/.+?/([^./]+)\.jpg$ /media/$1 [R=301,L,NC]
Upvotes: 0
Views: 84
Reputation: 784878
Your regex doesn't seem correct. You can use this rule in as first rule in your root .htaccess:
RewriteCond %{HTTP_REFERER} !example\.com$
RewriteRule ^uploads/images/.+?/([^./]+)\.jpg$ /media/$1.html [R=301,L,NC]
Upvotes: 1