jeremyapp Posted June 30, 2008 Share Posted June 30, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/112596-possibly-a-basic-question/ Share on other sites More sharing options...
rhodesa Posted June 30, 2008 Share Posted June 30, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/112596-possibly-a-basic-question/#findComment-578271 Share on other sites More sharing options...
jeremyapp Posted June 30, 2008 Author Share Posted June 30, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/112596-possibly-a-basic-question/#findComment-578332 Share on other sites More sharing options...
rhodesa Posted June 30, 2008 Share Posted June 30, 2008 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'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/112596-possibly-a-basic-question/#findComment-578356 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.