NameSilo

.htaccess - Help with relative path?

NamecheapNamecheap
Watch

TeviH

Established Member
Impact
2
Hey all!

I set up an .htaccess file to create a .php page when an image file is requested. This prevents hotlinking because php files won't load as a background or image inside someone's page. It would allow someone to simply link directly to an image, but then my website would be displayed around the image.

(found this pretty elegent method on alistapart: http://www.alistapart.com/articles/hotlinking/ )

Click here to see it in action, before I ask my question: photo

What I wanted to do was have the php file load my actual site design, like a template, with the image loading in the middle. When I did this, it wouldn't load any of the images in my design. The php file is in my root directory, so all links should have worked. (I'm guessing it has something to do with the relative path, in relation to wherever the main image is that is being hotlinked to?)

Did this make sense? Any advice?

Thanks :)
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
The file showpic.php and .htaccess should be in the same folder as the images.

For multiple images you might have to create multiple .php files (1 for each image) OR you can define a new array, add links to all the pictures in it and make
$pic1= newarray(picname1)
$pic2= newarray(picname2)
and so on...

when calling the image between html tags

<img src="/<?php echo($pic1); ?>" alt="Image">
<img src="/<?php echo($pic2); ?>" alt="Image">

and so on...
 
0
•••
Thanks for replying.

Defining a new array would be simplest, but that's not really what I was asking - let me try again:

I'll refer to the image being hotlinked to as Photo, while any interface graphics will just be graphics.

Currently, when someone hotlinks directly to any image on my website (Photo), it will be displayed with a little blurb of text saying it's mine with a link back to my site. What I tried to do, which didn't work, was simply make the Photo load up within the interface of my site, keeping my design. I changed "showpic.php" to reflect this, but none of the interface graphics loaded. The paths are correct in showpic.php.

Any idea why this isn't working?
 
0
•••
can anybody help?! :-/
 
0
•••
I am not sure if this would be possible... not saying it is impossible. I've never seen anything like this in action. That was the only piece of advice I could give...
 
0
•••
Dynadot — .com TransferDynadot — .com Transfer
CatchedCatched

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy — Zero Commission
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back