hello everyone .. i am pretty new to php programming and web development and i need to ask this. i have designed a few websites for my clients and i am getting better and now i have started learning php to add dynamic feel to the websites. my question is whenever i create links in my pages i do something like <a href="index.php">HOME</a>, <a href="aboutUs.php">ABOUT US</a> and so on. So i uploaded the website and whenever i view the source code the links appear exactly like that yet in other professional websites i have seen i always see something like <a href="http://www.facebook.com/home.php">HOME</a> for example.
what am i doing wrong. how can i make better links to other pages. what is the use of building links in that format. thank you.

Recommended Answers

All 3 Replies

the easiest way to do this is

<a href="<?php echo "http://".$_SERVER['HTTP_HOST']; ?>/yourpage.php">Click Me!</a>

but I'm not realy sure thats what you wanted. Do you mean how do you get your home page to be called home.php?

Member Avatar for diafol

I think I understand what you mean. The full url (http://....) is only really necessary if you're linking to external websites. Your own urls are fine. The only thing you have to look out for is 'relative' and 'absolute'. For me, making urls absolute (begin with '/') saves a lot of hassle.

For pages in your site, you don't need the http part. I think Ardav has provided a better explanation on this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.