Jump to content

Possibly a basic question


jeremyapp

Recommended Posts

Hi,

 

I hope this question is in the right place...

 

I work for a publishing company and we are selling eBooks versions of our print books on our website.  Our structure for the eBook directory looks like this:

 

public_html/eBooks/Flash/(name of eBook)/Default.php

 

As a result, the address for each eBook is:

 

http://www.(my domain).com/eBooks/Flash/(name of eBook)/Default.php

 

Currently, I use a script to check for authorization and then forwards to the correct eBook - however, there is a huge fault in this (i.e. people can access the books directly).  I know I can authenticate from the eBook php pages directly, but I was hoping there was a way I could serve these pages from outside the webroot.

 

i.e. the structure would look like this:

 

http://www.(my domain).com/eBooks/(name of eBook).php - Authenticates and then serves:

(some directory other than public_html/eBooks/Flash/(name of eBook)/Default.php

 

So finally, my question is - will apache allow me use a php page to serve files outside of my webroot (i.e. using an include)?  If so, how would I do it?

 

Thanks.

Link to comment
Share on other sites

Not that I am aware of...PHP will have to do that work. The common way that I have seen to do this is by passing the name of the book as an argument to the PHP script...like this:

http://www.domain.com/eBooks/Flash/book.php?name=(name of eBook)

Have PHP then access that eBooks info, which is stored in a folder outside of webroot, and return it.

 

Then, to make it more SEO friendly, you can use Apache's mod_rewrite to make

http://www.domain.com/eBooks/Flash/(name of eBook)

translate to the first URL

Link to comment
Share on other sites

I'm running into all kinds of trouble with this.  The biggest is that my php page, now stored outside the webroot, has references to flash files, which as it seems, can't be stored outside the webroot and still served to users.  Any way to get around this?

Link to comment
Share on other sites

The URL to get the Flash file needs to be in webroot for the client's browser to access it. But, you can wrap it with PHP, which can then in turn validate the user:

 

<?php
//Code to validate user here

//If they are good, send the flash file
header('Content-type: application/x-shockwave-flash');
print file_get_contents('/path/outside/of/webroot/flash.swf');
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.