Forum Moderators: phranque

Message Too Old, No Replies

.HTACESS Issues

         

vincenyc

7:46 am on Dec 28, 2009 (gmt 0)

10+ Year Member



Looking for a way to pass image url as a variable using htaccess, for ex:

www.example.com/testdir/http://i.walmartimages.com/i/p/00/08/52/14/04/0008521404841_215X215.jpg

my site url is:
http://www.example.com/testdir/

the image i'm looking to pass as a variable is:
[i.example2.com...]

Here's what I have so far, but it doesn't seem to work...

RewriteEngine on
RewriteRule ^test1/([a-zA-Z0-9_-]+)$ index.php?sImgUrl=$1
RewriteRule ^test1/([a-zA-Z0-9_-]+)/$ index.php?sImgUrl=$1
RewriteRule ^test1/([http://\A-Za-z0-9\.\_\-/\]+[A-Za-z0-9\.\_\-]+(\.gif¦\.png¦\.jpe?g)+)$index.php?sImgUrl=$1
RewriteRule ^test1/([\A-Za-z0-9\.\_\-/\]+[A-Za-z0-9\.\_\-]+(\.gif¦\.png¦\.jpe?g)+)$ index.php?sImgUrl=$1

[edited by: eelixduppy at 4:20 pm (utc) on Dec. 28, 2009]
[edit reason] exemplified [/edit]

jdMorgan

4:38 pm on Dec 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This one appears to be the 'closest' to working and doing what you want to do.

RewriteRule ^test1/([http://\A-Za-z0-9\.\_\-/\]+[A-Za-z0-9\.\_\-]+(\.gif¦\.png¦\.jpe?g)+)$index.php?sImgUrl=$1

But the regex pattern syntax needs some work, and you'll need an [L] flag on there for efficiency.

Try this instead:


RewriteRule ^test1/(http://([^.]+\.)+(gif¦png¦jpe?g))$ index.php?sImgUrl=$1 [L]

This will pass an incoming client request for example.com/test/http://<something>\.gif to your script at /index.php with a query string of "sImgUrl=<something>.gif"

The negative-match-on-periods pattern will speed things up a bit.

Replace all broken pipe "¦" characters above with solid pipes before use; Posting on this forum modifies the pipe characters.

Jim