user4904589
user4904589

Reputation: 565

Why RewriteRule isn't working in this case?

Here is my .htaccess.

ErrorDocument 404 /error/404.php

RewriteEngine On
RewriteRule ^\/images\/(.*)\.png$ /images/%1.jpg    

Now what I want to do is that http://blabla1001.net46.net/images/pegion.png should be redirected to http://blabla1001.net46.net/images/pegion.jpg but this does not happen instead I am getting redirected to 404.php.

Why is this happening?

Here is my directory structure:
enter image description here

Upvotes: 2

Views: 30

Answers (1)

anubhava
anubhava

Reputation: 785266

%1 is actually back-reference for value captured in RewriteCond, use $1:

ErrorDocument 404 /error/404.php
RewriteEngine On

RewriteRule ^(images/.+?)\.png$ /$1.jpg [NE,L,NC,R=302]

Upvotes: 2

Related Questions