Page 1 of 1

Absolute URL creation with PHP

Posted: Wed Mar 04, 2009 5:52 pm
by christinemarie
Hello,

I've never used PHP before, and was advised that it was the best method for creating an absolute URL in the situation described below.

My navigation is in one div, while all other pages for the site are loaded via ajax into a div below it. If the base url is http://www.mysite.com/index.html, for example. When a visitor clicks Page Two, and pagetwo.html loads into the div below, the address bar still says http://www.mysite.com/index.html. I would like for it to change to http://www.mysite.com/pagetwo.html.

Can anyone advise me on how this can be done, keeping in mind that I am a full-fledged beginner to PHP. I can provide links/code if necessary.

Thanks in advance,
Christine

Re: Absolute URL creation with PHP

Posted: Wed Mar 04, 2009 9:21 pm
by requinix
Don't use AJAX - just use normal links like everybody else does.

Code: Select all

<a href="/pagetwo.html">Page 2</a>
Which has a corollary:
You can't change what you see in the address bar without browsing to another page.

Re: Absolute URL creation with PHP

Posted: Thu Mar 05, 2009 5:51 am
by christinemarie
I have to use ajax if I want my page to open in a specific div. Otherwise an iFrame. But I am going to try looking into Dreamweaver to see if there's a function built-in for doing this.

Re: Absolute URL creation with PHP

Posted: Thu Mar 05, 2009 6:59 am
by Reviresco
You have to reload the page. The whole purpose of Ajax is to allow loading of content without reloading the page -- so you have to choose one or the other.

Re: Absolute URL creation with PHP

Posted: Thu Mar 05, 2009 7:40 am
by christinemarie
A programmer friend of mine suggested the following, which is why I posted here initially:

Make your new page page.php (instead of page.html) and put some scripting in it to tell if it is being accessed directly or via AJAX. If via AJAX, just return what is currently there. If it is directly, then wrap the current content with the header and footer. You could probably do the same thing with javascript.

Re: Absolute URL creation with PHP

Posted: Thu Mar 05, 2009 9:26 am
by papa
Ajax is javascript. :)