Welcome to WebmasterWorld Guest from 54.158.214.111

Forum Moderators: incrediBILL

Message Too Old, No Replies

relative links question about my PHP include?

     
10:19 pm on Mar 25, 2008 (gmt 0)

Junior Member

5+ Year Member

joined:Dec 23, 2007
posts:143
votes: 0


So in my PHP include I have three links and they all look like this ../index.php I have three different folders in my site root. My problem is I can't get the links to work for all three of the folders. If I do the relative link like this index.php then it works for the other half. Do I have to do absolute links then for the php include? Thanks
12:52 am on Mar 26, 2008 (gmt 0)

Full Member

5+ Year Member

joined:Mar 22, 2008
posts: 317
votes: 0


Could you explain the question more clearly please? Actually, this thread belongs in th PHP category, not the Browser Side World category.
12:56 am on Mar 26, 2008 (gmt 0)

Junior Member

5+ Year Member

joined:Dec 23, 2007
posts:143
votes: 0


I'll repost it over there, OK?
2:08 am on Mar 26, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
posts:37301
votes: 0


This still might be an html issue. Are each of these directories only one level deep? If so, then ../ will take you back to the domain root - and index.html would be the bare domain's index page. If some uses of the include are more than one folder deep, then you need ../../

The big question is what does "work" mean - are you trying to send the user to the domain root? If so, then it's not a good practice to use index.html - use http://www.example.com/ instead. If you're trying to send people to the home page of the same directory where the include is being used, then you don't need any ../ at all.

2:16 am on Mar 26, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member marcia is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Sept 29, 2000
posts:12095
votes: 0


For using includes on pages in /directories/ the easiest way is to put the includes into their own directory called /includes/ and call the includes for the pages like this:

<?php include("../includes/thecode.php"); ?>

Just disable the main page of /includes/ from being viewable using an Apache deny or by uploading a blank index page. That's basically for privacy and security reasons.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members