mercredi 29 avril 2015

.htaccess RewriteRule for image URL

At the moment i have the following .htaccess rewrite rule:

RewriteCond %{HTTP_HOST} ^blitz.example.com.s3-ap-southeast-1.amazonaws.com$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L]

I am trying to rewrite the following URL so that it points to the actual URL (see 2nd link below):

http://ift.tt/1GA7IbF

Where as i need to create a RewriteRule that points to the real actual URL which is:

http://ift.tt/1Edev7o

Can anyone help me with this ? I am really confused with this RewriteRule and regex.

EDIT

I want to use URLs like the followings :

http://ift.tt/1GA7IbF

and rewrite it with another domain like the followings :

http://ift.tt/1Edev7o

So far if i use the following html tag

<img src="http://ift.tt/1GA7IbF">

it returns 404

EDIT 2

Interestingly enough the following code also returns 404 error

<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} ^blitz.example.com.s3-ap-southeast-1.amazonaws.com$
RewriteRule ^(.*)([0-9]+)([0-9]+)([0-9]+)([0-9]+)-([a-zA-Z0-9_\-/.]+)/([a-zA-Z0-9_\-/.]+)$ img/p/$2/$3/$4/$5/$2$3$4$5-$6.jpg [L]
</IfModule>

EDIT 3

Out of desperation, i put only the following code on my .htaccess:

<IfModule mod_rewrite.c>

RewriteRule ^(.*)([0-9]+)([0-9]+)([0-9]+)([0-9]+)-([a-zA-Z0-9_\-/.]+)/([a-zA-Z0-9_\-/.]+)$ img/p/$2/$3/$4/$5/$2$3$4$5-$6.jpg [L]

</IfModule>

There is no other code in .htaccess, yet it still returns 404.

Aucun commentaire:

Enregistrer un commentaire