xampp serve pdfs outside of root directory

Problems with the Windows version of XAMPP, questions, comments, and anything related.

xampp serve pdfs outside of root directory

Postby MarkK » 20. April 2018 14:27

I have xammp installed, apache and mysql on my server, installed as a windows service. I have loaded some data into the database, and wrote a new index page to serve up the data, depending on user input to the page. Kind of a search page for data on a part number input, I work for a manufacturer, you enter a part number on the page, the page loads the part's description, drawing number, etc. The page also builds a link to the pdf drawing file of the part number. This pdf sits outside the htdocs folder, it is on the same letter drive, but not in the same install directory of xampp. When I try the link, I get the 403 access error. How do I get xampp to serve the pdf drawing file?

Things I have tried: editing config files changing some allow overrides and require all. I did restart xammp after this but not the entire server. I am still getting the access denied 403 error.

First, is it possible to do what I need (serve up a pdf from outside the root). If it is possible.....how? Am I on the right track or not?

I was going to include a picture of the directory structure, but it appears you can't upload a picture directly to the forums? You have to upload it to your own website and link it here......bummer.

Thanks for your help.
MarkK
 
Posts: 9
Joined: 20. April 2018 13:52
XAMPP version: v3.2.2
Operating System: Windows

Re: xampp serve pdfs outside of root directory

Postby Nobbie » 20. April 2018 22:32

MarkK wrote:First, is it possible to do what I need (serve up a pdf from outside the root). If it is possible.....how? Am I on the right track or not?


Of course it is possible. Two popular solutions:

a) either via VirtualHosts, define a new SubDomain (i.e. pdf.mydomain,com or so) and assign the DocumentRoot of your needs.

b) or use ALIAS to define a path to a folder different from root.

In any case you have to grant sufficient rights to Apache to access the folder (via "Require ...." clause").


And, yes, all of this requires reading the Apache documentation, configuring Apache is quite a sophisticated task.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: xampp serve pdfs outside of root directory

Postby MarkK » 23. April 2018 13:17

Nobbie,

Thanks for the reply.

I do not have experience with either of your solutions. Can you expand, or point me to the Apache documentation that further explains what I need to do?
MarkK
 
Posts: 9
Joined: 20. April 2018 13:52
XAMPP version: v3.2.2
Operating System: Windows

Re: xampp serve pdfs outside of root directory

Postby Nobbie » 23. April 2018 14:36

Apache documentation: https://httpd.apache.org/docs

Apache documentation VirtualHosts: https://httpd.apache.org/docs/2.4/en/vhosts/

Apache documentation ALIAS: https://httpd.apache.org/docs/2.4/en/mo ... html#alias
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: xampp serve pdfs outside of root directory

Postby MarkK » 24. April 2018 15:44

I am still struggling. I read the documentation for VirtualHosts and ALIAS, but am obviously failing to get either to work. I have attached a picture of my file structure (where index.php is and the pdf files I want to serve). Can you perhaps point me to the config files I need to change for either method of making this work? Possibly give a bit more detailed instructions?

Image

Hopefully the image is inline.

I don't think the image is there, here's my file structure:

Here are where the pdfs are stored: //main2016/engineering/approved_drawings
Here is where xampp is: //main2016/engineering/database
MarkK
 
Posts: 9
Joined: 20. April 2018 13:52
XAMPP version: v3.2.2
Operating System: Windows

Re: xampp serve pdfs outside of root directory

Postby Nobbie » 24. April 2018 21:25

Show us your configuration please, what did you enter into your config files? For virtualhosts you have to adapt httpd-vhosts.conf in ./extra folder, and ALIAS you can adapt whereever you want (i.e. httpd.conf).
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: xampp serve pdfs outside of root directory

Postby MarkK » 25. April 2018 16:23

I do not see a way to attach files this forum post? I was going to attach my httpd.conf file, with an ALIAS attempt.

Here is what I added to my httpd.conf file:

<Directory "/Mark/temp">
Require all granted
</Directory>

Alias "/temp" "/Mark/temp"

Then from my index page, I am serving up a link that points to:

http://localhost/C:/Mark/temp/01-3200.pdf

When the link opens in a new tab, I get the access forbidden 403 error. I can get to the file in the new tab, if I delete 'localhost' from the url in the address bar.

I can copy/paste my entire httpd.conf file if needed into the body of the post? Just seems like there would be a way to attach to the post instead.
MarkK
 
Posts: 9
Joined: 20. April 2018 13:52
XAMPP version: v3.2.2
Operating System: Windows

Re: xampp serve pdfs outside of root directory

Postby Altrea » 26. April 2018 00:06

MarkK wrote:http://localhost/C:/Mark/temp/01-3200.pdf

Sorry, but this is nonsense.
A valid URL related to your Alias configuration would be http://localhost/temp//01-3200.pdf

But your whole Alias and Directory definition is incomplete. You need to provide a full qualified directory path like C:/Mark/temp, not only /Mark/temp
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: xampp serve pdfs outside of root directory

Postby MarkK » 26. April 2018 14:30

Nobbie and Altrea,

I appreciate your help (even the nonsense comment)! It is working as expected currently.

Thank you

Mark
MarkK
 
Posts: 9
Joined: 20. April 2018 13:52
XAMPP version: v3.2.2
Operating System: Windows


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 150 guests