| | #1 |
| Brian Kindsvater War Room Member Join Date: 2004 Location: Sparta
Posts: 4,084
Thanks: 153
Thanked 4,818 Times in 1,585 Posts
Blog Entries: 190 |
I have a script that creates a nice 'SEO'd' looking link to an eBay image (eg: mysite.com/images/123435.jpg) and using htaccess shows the real image at thumbs.ebaystatic.com/pict/123435.jpg This is the htaccess rewrite code: RewriteRule ^images/(.*)$ http://thumbs.ebaystatic.com/pict/$1 [R,L] No big deal. Except my web page still shows 123435.jpg which can readily be identified as an eBay image. What I am doing is changing my SEO link to be: images/12Z4Z5.jpg (easy enough to do a string replace in php to change every "3" to a "Z" - I am changing every occurrence of "3" in the image name wherever it appears) This is where I need your help. How do I add to or change my htaccess rewrite code to change every "Z" back to a "3" wherever it may be in a link so that the correct eBay image is retrieved? Example: how do I do this in htaccess: /images/12Z4Z5.jpg retrieves thumbs.ebaystatic.com/pict/123435.jpg /images/1Z7982.jpg retrieves thumbs.ebaystatic.com/pict/137982.jpg etc. $20 payment made via PayPal to first person who can solve this, with me verifying it works on my website. |
| |
| | #2 |
| PeaceRoom Member Join Date: 2011 Location: Montreal, Canada
Posts: 85
Thanks: 12
Thanked 9 Times in 9 Posts
|
try this: Code: RewriteRule ^images/([^Z]*)Z(.*) http://thumbs.ebaystatic.com/pict/$1\3$2 [N] WP4H |
| |
| | #3 |
| VIP Warrior War Room Member Join Date: 2006 Location: , , USA.
Posts: 1,795
Thanks: 70
Thanked 287 Times in 259 Posts
|
Since you don't know how many "Z"s there will be, you won't be able to do it directly in the .htaccess file. Well you could, but you would have to code it for every possibility for the qty of "Z"s the file name may have. What you could do, is pass it to a script on your site which then redirects to the image. I just wrote something like that, but it was for local images. I can now put any keyword as the filename and always pull up the same image because of the way I parse the url. |
| |
| | #4 |
| Brian Kindsvater War Room Member Join Date: 2004 Location: Sparta
Posts: 4,084
Thanks: 153
Thanked 4,818 Times in 1,585 Posts
Blog Entries: 190 |
WP4H: For some reason only one "Q" is being replaced. I believe the [N] at the end is supposed to be recursive, but it isn't so this fails if there is more than one Q. Let me see if I can figure how to do a php string replace of only the 1st instance of a "3" to try and get this to work. Kirk: eBay images are apparently 12 digits long. That seems to be a fixed number. |
| |
| | #5 |
| Advanced Warrior War Room Member Join Date: 2006 Location: USA
Posts: 1,907
Thanks: 236
Thanked 1,377 Times in 676 Posts
| |
| | |
| |
| | #6 |
| Brian Kindsvater War Room Member Join Date: 2004 Location: Sparta
Posts: 4,084
Thanks: 153
Thanked 4,818 Times in 1,585 Posts
Blog Entries: 190 |
Thanks. One issue still out there is that if there is no text to replace the image does not load. I didn't see this issue earlier but have since using the preg_replace. But since it appears virtually every eBay image has a zero in it, I'll use replacing the first zero instead of a 3.
|
| |
| | #7 |
| PeaceRoom Member Join Date: 2011 Location: Montreal, Canada
Posts: 85
Thanks: 12
Thanked 9 Times in 9 Posts
|
Hi kindsvater, Sorry to hear the rewriteRule did not work as planned. I set it up on my server and it did the job, but then I don't have the same setup or know the full problem set. No need to send me $$$, I only accept when the solution is complete! Consider it free help, hopefully it got you closer to your goal ![]() Cheers, WP4H |
| |
|
| Bookmarks |
| Tags |
| $20, htaccess, issue, replace, solve, text |
| |