Page 1 of 1

Issue with paths in Apache

PostPosted: 05. July 2012 22:44
by Ravarix
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

Re: Issue with paths in Apache

PostPosted: 05. July 2012 22:54
by Altrea
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