1

I have indexed several images that I need to redirect using .htaccess

The old urls are like:

example.com/oscthumb.php?src=/images/3-A_in.jpg&w=960&h=647&f=jpg&q=95&hash=6b884jduhh3h8737h

and they have to become:

example.com/images/3-A_in.jpg

Images can have any image extensions and any file name. This part

oscthumb.php?src=/images/

is always the same.

I tried several options using .htaccess online testers but I'm unable to make it work.

1 Answers1

0

To redirect the old URLs to new ones , you can use the following rule in your .htaccess file :

RewriteEngine on

RewriteCond ℅{THE_REQUEST} /oscthumb\.php\?src=/images/([^\s]+)\s [NC]
RewriteRule ^.+$ http://example.com/images/%1? [L,R]

Change R to R=301 to make the redirection permanent when you are sure the rule is working ok.

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
  • Thank you. I've tried it but it doesn't redirect, returns a 404 error. It is a Prestashop installation, do you know the reason? – andrewbaltimore Nov 08 '18 at 19:17