Jump to content

.htaccess image redirection


Recommended Posts

Given the following full URL of my image:
 
 
 
 
I would like to create a ReWriteRule on my .htaccess in such a way that i rewrite the the link below into the above URL:
http://blitz.example.com.s3-website-ap-southeast-1.amazonaws.com/3478-product_list_default/green-army-combats-type-i.jpg
 
This is my latest attempt of doing so, but still got no luck. Meaning the RewriteRule below generates the URL i mentioned above.
 
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]
 
 
Can anyone help me with this ?
Edited by sibrodo (see edit history)
Link to comment
Share on other sites

@Dh42, i am using S3 as my CDN so i think it does not honor .htaccess file.

 

I ended up trying using this in my .htaccess

 

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_\-/.]+)$ blitz.example.com.s3-ap-southeast-1.amazonaws.com/img/p/$1/$2/$3/$4/$1$2$3$4-$5.j$
 
 
 
The given Regex is valid against this: 3478-product_list_default/green-army-combats-type-i.jpg
 
and can be verified here: http://regexr.com/3at3b
 
The problem is simple yet so complex, basically i want to use the following URL:
 
 
so that it rewrites to:
 
Edited by sibrodo (see edit history)
Link to comment
Share on other sites

I just learned that the following RewriteRule (desipite it is valid), will yields an Server Error 404

 

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]
Edited by sibrodo (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...