Page 1 of 1

Relative and root relative nav links break on testing server

PostPosted: 11. March 2010 06:28
by jklockow
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.

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

PostPosted: 11. March 2010 12:12
by evolutionxbox
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 (../).

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

PostPosted: 12. March 2010 05:43
by jklockow
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')
?>

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

PostPosted: 12. March 2010 05:56
by Altrea
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.

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

PostPosted: 12. March 2010 17:55
by jklockow
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?

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

PostPosted: 12. March 2010 20:25
by Altrea
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.

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

PostPosted: 13. March 2010 06:44
by jklockow
Excellent. I'll try one of those. Thanks for replying!