Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 14th Jan 2011, 01:24 PM   #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
Default
Thanks - solve an htaccess replace text issue
Share on: 
fb share twitter share gplus share more share

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.
kindsvater is offline  
Unread 14th Jan 2011, 02:29 PM   #2
PeaceRoom Member
 
webpro4hire's Avatar
 
Join Date: 2011
Location: Montreal, Canada
Posts: 85
Thanks: 12
Thanked 9 Times in 9 Posts
Default
Re: $20 to solve an htaccess replace text issue
Share on: 
fb share twitter share gplus share more share

try this:

Code:
RewriteRule ^images/([^Z]*)Z(.*) http://thumbs.ebaystatic.com/pict/$1\3$2 [N]
Cheers,
WP4H
webpro4hire is offline  
Unread 14th Jan 2011, 02:56 PM   #3
VIP Warrior
War Room Member
 
Join Date: 2006
Location: , , USA.
Posts: 1,795
Thanks: 70
Thanked 287 Times in 259 Posts
Default
Re: $20 to solve an htaccess replace text issue
Share on: 
fb share twitter share gplus share more share

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.
KirkMcD is offline  
Unread 14th Jan 2011, 03:59 PM   #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
Default
Re: $20 to solve an htaccess replace text issue
Share on: 
fb share twitter share gplus share more share

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.
kindsvater is offline  
Unread 14th Jan 2011, 06:51 PM   #5
Advanced Warrior
War Room Member
 
Brandon Tanner's Avatar
 
Join Date: 2006
Location: USA
Posts: 1,907
Thanks: 236
Thanked 1,377 Times in 676 Posts
Default
Re: $20 to solve an htaccess replace text issue
Share on: 
fb share twitter share gplus share more share

Originally Posted by kindsvater View Post

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.
<?php
$string = '1234512345';
$replaced = preg_replace('/3/', 'Z', $string, 1);
?>

In the example above, $replaced would output '12Z4512345'


Brandon Tanner is offline  
Unread 14th Jan 2011, 07:24 PM   #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
Default
Re: Thank - solve an htaccess replace text issue
Share on: 
fb share twitter share gplus share more share

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.
kindsvater is offline  
Unread 14th Jan 2011, 07:57 PM   #7
PeaceRoom Member
 
webpro4hire's Avatar
 
Join Date: 2011
Location: Montreal, Canada
Posts: 85
Thanks: 12
Thanked 9 Times in 9 Posts
Default
Re: Thanks - solve an htaccess replace text issue
Share on: 
fb share twitter share gplus share more share

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
webpro4hire is offline  
Closed Thread


Bookmarks

Tags
$20, htaccess, issue, replace, solve, text


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 02:10 AM.