Page 1 of 1

Link to drive D: -don't have permission

PostPosted: 02. February 2024 19:35
by FKlusmann
I wish to use files on D:/ as well those in C:/xmapp/htdocs Using XAMPP for Windows 8.1.6
I added with (3 lines)
Code: Select all
<Directory "D:/">      Require all granted    </Directory>
to httpd.conf.
I still get: Forbidden You don't have permission to access this resource. Apache/2.4.53 (Win64) OpenSSL/1.1.1n PHP/8.1.6 Server at localhost Port 443

The log says: [pid 14004:tid 1976] (20023)The given path was above the root path: [client 127.0.0.1:62749] AH00127: Cannot map GET /D:/mysite/index.html HTTP/1.1 to file, referer: https://localhost/mysite/index.html
Code used:
Code: Select all
 
<!-- This link works: -->
<a href="./HTML/test.html" target="_blank" rel="noopener">Old on drive C:</a>
<!-- This link fails and gives the error shown: -->
<a href="../../../../D:/mysite/index.html" target="_blank"
      rel="noopener">New on drive D:</a>

Thank you for taking the time to read, and suggest a solution.

Re: Link to drive D: -don't have permission

PostPosted: 02. February 2024 22:41
by Nobbie
That does not work at all! You MUST NOT provide a local pathname in an http-based URL.

Instead define an ALIAS in your Apache configuration and use this ALIAS in the href statement of your index.html.

For example:

Add

Code: Select all
ALIAS /myfiles D:/mysite


in your httpd.conf and provide that ALIAS in your URL:

Code: Select all
<a href="http://localhost/myfiles/index.html" target="_blank"
      rel="noopener">New on drive D:</a>


And dont forget to grant appropriate rights to D:/mysite in httpd.conf, for example:

Code: Select all
<Directory D:/mysite>
...
Require all granted
</DIrectory>


If you forget, you will get Error 403. Also keep in mind, that driveletters to USB or Netdrives are limited to the logged in user. You cannot provide these, when you run Apache as a service (as it is executed by "System" user instead of your UserID). You will get Error 404 if Apache cannot read D:/mysite.

Finally read the Apache Documentation about ALIAS: https://httpd.apache.org/docs/2.4/mod/m ... html#alias

Re: Link to drive D: -don't have permission

PostPosted: 02. February 2024 22:52
by FKlusmann
Thank you, Nobbie.

I am trying your suggestions.

Re: Link to drive D: -don't have permission

PostPosted: 02. February 2024 23:44
by FKlusmann
I still fail.

In httpd.conf

The Directory block is:

<Directory />
AllowOverride none
Require all denied
</Directory>

ALIAS /drive-d D:/mysite

<Directory drive-d>
Require all granted
</Directory>

The test link is:
The new link is:
<a href="http://localhost/drive-d/index.html">New on drive D: with http://localhost/drive-d/index.html:</a>

The error log is:
[Fri Feb 02 16:30:56.017046 2024] [authz_core:error] [pid 28888:tid 1972] [client 127.0.0.1:63608] AH01630: client denied by server configuration: D:/mysite/index.html

Re: Link to drive D: -don't have permission

PostPosted: 02. February 2024 23:56
by Nobbie
FKlusmann wrote:I still fail.


Of course.

As this is plain nonsense:

<Directory drive-d>
Require all granted
</Directory>


Must be instead:

Code: Select all
<Directory D:/mysite>
Require all granted
</Directory>

Re: Link to drive D: -don't have permission

PostPosted: 03. February 2024 02:27
by FKlusmann
Thank you, Nobbie.
I changes permission to the real drive, not the alias. Now it works.
I left the alias name as drive-d as it is a bit more semantic.

You made sense out of my nonsense:
From my GIGO, made a salad

Re: Link to drive D: -don't have permission

PostPosted: 03. February 2024 02:56
by FKlusmann
By using the above, the page opens. The links from index.html do not.

For example, <link rel="stylesheet" href="./includes/styles.css"> did not work.

Please point me in the right direction.

Thank you.

Re: Link to drive D: -don't have permission

PostPosted: 03. February 2024 12:55
by Nobbie
That link should work. Is it really that URL? Either replace it by an absolute link

Code: Select all
href="http://localhost/drive-d/includes/styles.css"


or look into access-log and error-log in order to find out, why the relative link does not work. Where is the includes folder? Is it "includes" or maybe "include"? Is it at D:/mysite/includes? Etc. pp....

Re: Link to drive D: -don't have permission

PostPosted: 04. February 2024 00:58
by FKlusmann
I powered the machine on and this does work now.

I have no explanation.

Nobbie wrote:Is it really that URL?

Yes, it is.

Thank you for helping.