User / AJAX cannot access file directory

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

User / AJAX cannot access file directory

Postby Orifiael » 07. July 2021 13:09

Hello,

We have been trying many things this entire day now.
I use Xampp since forever to run my localhost websites.

Now a new employee has installed Xampp to work on his localhost too, but unlike me he cannot access his file directory.
And Ajaxcalls cannot find the files as well.

Our installations are not in C:/xampp/htdocs but are directed to a another folder (C:/projects/{projectname}). This is done in httpd.conf on the 2 places below, this always worked perfectly for me:
Code: Select all
DocumentRoot "C:/projects/{projectname}"
<Directory "C:/projects/{projectname}">


When I would go to 'localhost/api/' I would see all the files inside this folder, or even go to 'localhost/api/test.php' I would execute this file.
However my colleague (and another one in the past as well) get's a 404.
This also works when doing ajaxcalls, so even javascript cannot find the files with for example (`ajaxRequest.open('POST', './api/testreportsajax.php', true); `) (other URL variants don't change this, e.g. location.host + {url}), they all return 404.

p.s. The urls are correct, no need to comment on that, I have been doing this a long time.
If I put my documentroot on "c:/" I can even access my c:/windows files

We have been trying an endless amount of things, adding htaccess files with rewritecond, changing values in php.ini and httpd.conf, putting them on AllowOverride All & Require all granted.

Bottom line is, he cannot see his folder structure when opening localhost through the browser and also javascript cannot find the files (only php finds the includes and requires). Thus all our API calls don't work with Ajax.
Initially he downloaded the latest version, but he even downgraded the version to my version.
Not only that but we literally used a notepad++ plugin (compare) to compare every single config and ini file, which were similar or made similar.
Also changing ports didn't help.

Question is: What is causing him to not be able to access his filesystem through the browser's address bar, and more importantly, how do we fix it, because our Centos 7 apache servers have no problem accessing the file systems or executing ajax scripts.
Orifiael
 
Posts: 5
Joined: 07. July 2021 12:53
XAMPP version: 7.4.8
Operating System: Windows 10

Re: User / AJAX cannot access file directory

Postby Altrea » 07. July 2021 15:46

hi,

what is {projectname}, where did you define it?
i only know this syntax from using environment variables (SetEnv) or constants (Define) but than the syntax would be ${projectname}
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: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: User / AJAX cannot access file directory

Postby Orifiael » 07. July 2021 15:57

I just meant it could be any name, didn't want to give our customers project name. For this let {projectname} be simply "test" then
DocumentRoot "C:/projects/test"
<Directory "C:/projects/test">
Orifiael
 
Posts: 5
Joined: 07. July 2021 12:53
XAMPP version: 7.4.8
Operating System: Windows 10

Re: User / AJAX cannot access file directory

Postby Nobbie » 07. July 2021 16:10

But if you enter http://localhost/test into your browser, it yields to c:/projects/test/test and NOT c:/projects/test.

Is it really that what you want?

Actually i think that you need this setup:

Code: Select all
DocumentRoot "C:/projects"
<Directory "C:/projects">


OUCH!!??
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: User / AJAX cannot access file directory

Postby Orifiael » 08. July 2021 07:57

Is there anyway we can actually move on to the question I had?
The documentroot and so on is not a problem, everything works as I want to.

The question I had was, what settings cause me to see my index when I go to localhost/api and my colleague to not see the index (with all files and folder).
Orifiael
 
Posts: 5
Joined: 07. July 2021 12:53
XAMPP version: 7.4.8
Operating System: Windows 10

Re: User / AJAX cannot access file directory

Postby Nobbie » 08. July 2021 09:48

Didnt you understand my answer? According to your description your URL in the browser does not match the project folder. Maybe you should describe your problem better, you still did not show us a full pathname of a file which is not found.
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: User / AJAX cannot access file directory

Postby Orifiael » 13. July 2021 08:41

I realize that I may have wrote too much, making it confusing for some people.

There are 2 pcs, with exactly the same installation and XAMPP version.
We both have our project in C:/project and also our document root set to C:/project

Within the C:/project we have a folder called 'api' and in that folder a file called 'reports.php'
When I go to 'localhost/api' in any browser I see the folder index with the file 'reports.php'
When he goes to 'localhost/api' he will get a 404.

This may help you further:
We also have a /php and a /js folder.
We can BOTH access those folders and see the index in either installation.
Orifiael
 
Posts: 5
Joined: 07. July 2021 12:53
XAMPP version: 7.4.8
Operating System: Windows 10

Re: User / AJAX cannot access file directory

Postby Nobbie » 13. July 2021 10:12

You did not tell too much, you simply told wrong things.

It was ME that told you to set DocumentRoot to c:/projects. You instead told us that you set DocumentRoot to c:/projects/{projectname} like for example c:/projects/test . So you were the only one confused by yourself. So whats the truth now?

Anyway, look into the access log and into the error log, if properly configured you should get more valid information of what is going wrong. There may be a redirect on one PC going wrong.

If you only cannot get a directory listing, it may be caused by missing Option Indexes and/or wrong value for DirectoryIndex.
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: User / AJAX cannot access file directory

Postby Orifiael » 15. July 2021 08:22

Well it's technically still not c:\projects, but I had to redirect you from that subject to get an answer that was slightly more useful.
Anyway close this issue for now, we stopped using Xampp entirely, its just dated and works poorly.

We now work with virtual machines to create localhost machines, which worked a lot better if you can simply install Apache and PHP in a linux environment, allowing us to have much more freedom in setting out htaccess, without having to break through a rusty shell of extra protections and obstacles.
Orifiael
 
Posts: 5
Joined: 07. July 2021 12:53
XAMPP version: 7.4.8
Operating System: Windows 10

Re: User / AJAX cannot access file directory

Postby Altrea » 15. July 2021 08:42

Use the tool you want to be as productive as possible.

But don't blame XAMPP for having that much problems with your htaccess autoindex environment. This is such an easy topic where XAMPP is configured straight forward. In fact it does not need that much configuration. XAMPP doesn't protect anything here.

Happy coding 8)
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: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: User / AJAX cannot access file directory

Postby Nobbie » 15. July 2021 10:16

A fool with a tool remains a fool.

But anyway, its always a good idea to switch over to linux, i dont use windows already for many years. That said, this problem is definately neither a windows problem nor a Xampp problem.
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 134 guests