Ulugbek
Ulugbek

Reputation: 141

Removing .jpg from url

I have rewrite rule that redirects users who try directly open image to the website post but I need to remove .jpg from url:

RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?example\.com [NC]
RewriteRule ^reviews-image/([^/]+) /image-2/$1 [L,NC,R=302]

Example: http://www.example.com/reviews-image/2015-lincoln-mkc-3.jpg to http://www.example.com/image-2/2015-lincoln-mkc-3.jpg

But I want remove .jpg from link so it would be http://www.example.com/image-2/2015-lincoln-mkc-3. How can I achieve that?

Upvotes: 0

Views: 190

Answers (1)

Croises
Croises

Reputation: 18671

You can use this .htaccess:

RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?example\.com [NC]
RewriteRule ^reviews-image/([^/]+)\.jpg /image-2/$1 [L,NC,R=302]

Upvotes: 1

Related Questions