Relative and root relative nav links break on testing server

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

Relative and root relative nav links break on testing server

Postby jklockow » 11. March 2010 06:28

Hi all,

Newbie question no doubt, but I couldn't find the answer when searching.

Just installed XAMPP. Install went great.

Here's the issue: My relative and root relative nav links break on the testing server on my machine but work fine on the live site. The files are within a folder inside htdocs. The testing server, however, seems to think that the htdocs folder is the site root, not the folder within htdocs where all the site files actually are.

So instead of generating a URL of http://localhost/healing/articles

instead I get http://localhost/articles, which comes up broken.

I should say that the nav code is generated on the server via a php include.

Questions: Is this a settings issue? If so where do I find that setting. Or have I misunderstood the proper way to set up sites within htdocs?

Anybody that has the patience to set me straight would be greatly appreciated.

Thanks.
jklockow
 
Posts: 7
Joined: 10. March 2010 06:58

Re: Relative and root relative nav links break on testing server

Postby evolutionxbox » 11. March 2010 12:12

Could you post some code that produces the url?
It could have something to do with either the php.ini or you maybe using the wrong relation thingy (../).
evolutionxbox
 
Posts: 10
Joined: 22. January 2009 10:40

Re: Relative and root relative nav links break on testing server

Postby jklockow » 12. March 2010 05:43

Sure thing. Thanks for replying. If that were the problem, wouldn't it break on the live site as well?

In any case, the index.php file pulls a header.html file using the code immediately below. But the header.html file includes a php require command that it pull in the nav.html file so it's a two-step process. I'm pretty sure I have the thingy right. :D


This code is in the index.php file:

<?php
ini_set ('display_errors',1);
error_reporting (E_ALL &~E_NOTICE);

define ('DESCRIPTION', 'Readings that outline some of the ideas at the center or our marriage and couples counseling practice.');

define ('KEYWORDS', 'Healing a marriage, mindfulness, couples counseling, marriage counseling, marriage therapy, what to expect');

define ('TITLE', 'Articles');

require ('../templates/header.html');
?>


This code is in the header.html file:

<?php
require ('../templates/nav.html')
?>
jklockow
 
Posts: 7
Joined: 10. March 2010 06:58

Re: Relative and root relative nav links break on testing server

Postby Altrea » 12. March 2010 05:56

jklockow wrote:If that were the problem, wouldn't it break on the live site as well?

No. Your Apache/PHP/MySQL version could be an other one than on the live server.
Your Configuration can be different as the one on the live server (and this is the case here).

jklockow wrote:But the header.html file includes a php require command

The default (and much cleaner) behavior of Apache is, to serve html files in plain text without sending them through the php parser. That breaks your code.
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: 8294
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Relative and root relative nav links break on testing server

Postby jklockow » 12. March 2010 17:55

Thanks Altrea for your time.

Just so I understand, then, is the solution to switch to SSI for the navigation so it will work on both? Or, if I can't control the behavior of the live server, is there some configuration change I can make to Apache locally so they match up?
jklockow
 
Posts: 7
Joined: 10. March 2010 06:58

Re: Relative and root relative nav links break on testing server

Postby Altrea » 12. March 2010 20:25

You have 3 possibilities:

1. configure Apache to serve all html files through the php interpreter too (can be done in the Apache config or .htaccess file)
2. use ServerSideIncludes
3. rename and change all your html files that contain php code to php file extension.

Depends on your own wishes. I don't know enough about why you name your files with html file extension instead of php.
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: 8294
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Relative and root relative nav links break on testing server

Postby jklockow » 13. March 2010 06:44

Excellent. I'll try one of those. Thanks for replying!
jklockow
 
Posts: 7
Joined: 10. March 2010 06:58


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 56 guests