Tim Holmes
Tim Holmes

Reputation: 31

Redirect one image to webpage Issue

I hope everyone is well.

I am having a few issues trying to redirect an image that was linked in error from an email to a html page.

For example the email points here - https://www.caravanguard.co.uk/news/wp-content/uploads/2021/03/Swift-Vogue-580-1.jpeg

But should point here - https://www.caravanguard.co.uk/news/make-mine-a-dealer-special-caravan-25644/

I have appplied the following to our .htaccess, but it does not appear to have worked. I have also done the same in the wordpress yoast plugin we use.

redirect 301 /news/wp-content/uploads/2021/03/Swift-Vogue-580-1.jpeg /news/make-mine-a-dealer-special-caravan-25644/

Any ideas?

Upvotes: 3

Views: 171

Answers (3)

Tim Holmes
Tim Holmes

Reputation: 31

Had to remove the image from wordpress before it would allow the redirect to work. WP rules seem to have got in the way. The .htaccess rule I originally created then kicked in.

I tried the above comments prior to the deletion and they did not work. Cheers for your help both.

Upvotes: 0

RavinderSingh13
RavinderSingh13

Reputation: 133538

With your shown samples, could you please try following. Please make sure to place these rules at top of your .htaccess file. Also please do clear your browser cache before testing any URLs.

RewriteEngine ON
RewriteRule ^news/wp-content/uploads/2021/03/Swift-Vogue-580-1\.jpeg/?$ /news/make-mine-a-dealer-special-caravan-25644/ [R=301,NC,L]

Upvotes: 3

Amit Verma
Amit Verma

Reputation: 41219

You can use a RewriteRule

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/news/wp-content/uploads/2021/03/Swift-Vogue-580-1.jpeg$
RewriteRule ^.+$ /news/make-mine-a-dealer-special-caravan-25644/ [R=301]

Make sure this rule is at the top of your htaccess or before your WordPress rules.

Upvotes: 2

Related Questions