jcombs_31 Posted May 11, 2007 Share Posted May 11, 2007 I was reading an article and it brought up something interesting. How do you link your pages? Do you use the absolute path with http://www.something.com/page1.php or do you use the relative path /page1.php ? I've always used a relative path, does it matter and what do you do? Quote Link to comment https://forums.phpfreaks.com/topic/50921-linking-your-pages/ Share on other sites More sharing options...
Daniel0 Posted May 11, 2007 Share Posted May 11, 2007 Relative, but I don't really think it matters. Relative paths are just shorter. Quote Link to comment https://forums.phpfreaks.com/topic/50921-linking-your-pages/#findComment-250462 Share on other sites More sharing options...
redbullmarky Posted May 11, 2007 Share Posted May 11, 2007 i never use the URL in my hyperlinks unless it's linking externally. It has been known for me to change domain names for a project and I'm not a fan of either using php to insert the domain (i tend to keep my HTML pages as HTML as possible) or search+replace+re-upload in the event of me changing the domain name (or going from a testing server to a proper one) I dislike syntax such as ./somewhere/test.php or ../somewhereelse/test2.php so I always start my links off with a / so they're all relative to the web root. Quote Link to comment https://forums.phpfreaks.com/topic/50921-linking-your-pages/#findComment-250464 Share on other sites More sharing options...
ober Posted May 11, 2007 Share Posted May 11, 2007 I'm with red on this one... all relative unless it's an external link or links to a different part of my site. Quote Link to comment https://forums.phpfreaks.com/topic/50921-linking-your-pages/#findComment-250492 Share on other sites More sharing options...
cmgmyr Posted May 11, 2007 Share Posted May 11, 2007 relative unless external Quote Link to comment https://forums.phpfreaks.com/topic/50921-linking-your-pages/#findComment-250694 Share on other sites More sharing options...
AndyB Posted May 12, 2007 Share Posted May 12, 2007 I always use relative links so I can test locally, and occasionally move stuff to other domains (as already noted) without any problems. So what was the article that sparked the question? Quote Link to comment https://forums.phpfreaks.com/topic/50921-linking-your-pages/#findComment-251301 Share on other sites More sharing options...
steviewdr Posted May 12, 2007 Share Posted May 12, 2007 Always relative. I try and make my sites as portable as possible. I.e they will run under a subdomain or a subfolder of a domain name, i.e. http://project.website.com or http://www.website.com/project. I also think google prefers relative links for SEO stuff. -steve Quote Link to comment https://forums.phpfreaks.com/topic/50921-linking-your-pages/#findComment-251389 Share on other sites More sharing options...
TheFilmGod Posted May 15, 2007 Share Posted May 15, 2007 Hard to say. I only use relative when php is combined. So I switch it around very easily. Other than that, I use absolute. Its much easier like that. I do large scale projects, and don't change domains. Quote Link to comment https://forums.phpfreaks.com/topic/50921-linking-your-pages/#findComment-253163 Share on other sites More sharing options...
steelmanronald06 Posted May 15, 2007 Share Posted May 15, 2007 I keep my dynamic. There are times when I need to get links that are controlled by cpanel to work on their directory and not the root. Sounds confusing, but here is what i do: <?php $path = ".."; $link = $path . '/index.php'; echo $link; require_once($path . 'includes/master.php'); unset($path); ?> stuff like that :-/ Quote Link to comment https://forums.phpfreaks.com/topic/50921-linking-your-pages/#findComment-253266 Share on other sites More sharing options...
Orio Posted May 15, 2007 Share Posted May 15, 2007 I like creating things dynamic. That's why I use relative paths. And even if I need to use a full address (like in an email for confirming a registration or something like that) I do things like this: <?php $url = "http://".$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF'])."/activation.php"; ?> This makes things dynamic as possible. Orio. Quote Link to comment https://forums.phpfreaks.com/topic/50921-linking-your-pages/#findComment-253383 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.