Issue with paths in Apache

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

Issue with paths in Apache

Postby Ravarix » 05. July 2012 22:44

Hi fellow xamppers,

I recently started using Xampp and am really enjoying it, however I am having a problem that I can't seem to fix. I placed the website I am working on in /xampp/htdocs/sccdev, and I have an index.php in the sccdev folder. The index displays fine with the path "http://localhost/sccdev/index.php", if I then click on a link with an href="/contact_demo.php", it redirects me automatically to "localhost/contact_demo.php" instead of preserving the sccdev folder path. This of course causes as 404 error as there is no contact_demo.php in my htdocs folder.

Once more, if I manually change the url to "localhost/sccdev/contact_demo.php", I get a blank page.

Thanks,

DC
Ravarix
 
Posts: 1
Joined: 05. July 2012 22:32
Operating System: Win 7 Prof

Re: Issue with paths in Apache

Postby Altrea » 05. July 2012 22:54

Hi Ravarix,

Ravarix wrote:if I then click on a link with an href="/contact_demo.php", it redirects me automatically to "localhost/contact_demo.php" instead of preserving the sccdev folder path.

Which is absolute correct. An url with a beginning slash is root relative and the root is http://localhost

Ravarix wrote:Once more, if I manually change the url to "localhost/sccdev/contact_demo.php", I get a blank page.

Maybe because of other root relative paths.

You have two possibilities: use script-relative paths (just get rid of the beginning slash) or change the Document_root for your Apache or create a virtualhost with a new documentroot.

best wishes,
Altrea
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: 11933
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 160 guests