Jump to content

Recommended Posts

I have a site that can be accessed through multiple URL avenues:

 

www.WallCrawlersWeb.com

 

is also

 

www.SpideyDatabase.com

 

and

 

Spider-man.Comics-Database.com

 

because of folder structure and such, I can't use relative paths to links, and need to use absolute paths, but don't want to redirect to only one URL (the way I have been up until now.)

 

Is there a way to create a variable like

 

$BaseHref

 

that I can populate with the URL that the visitor has in their address bar INCLUDING the one utilizing a sub-domain? I found this page on the drupal site

 

http://drupal.org/node/6554

 

that might work - just don't know if it will work on the sub-domain version.

Link to comment
https://forums.phpfreaks.com/topic/40748-solved-create-base-url-variable/
Share on other sites

Thanks for the quick reply, but due to my server structure, that won't work - it's complicated... the entire website in question is in the folder "spider-man" in the folder "comics-database". My main URL is actually totally unrelated, www.vynsane.com - that's my document_root. basically to get to my spider-man site, you have to go to

 

public_html/comics-database/spider-man/

 

so I need a more round-about way of doing it...

 

 

found that this works, even with a sub-domain:

 

$baseURL = $_SERVER['HTTP_HOST'];

 

FYI, anyone who needs to do this - you have to put the 'http://' in front of your echoed variable before it will work, like this:

 

<?php
$baseURL = $_SERVER['HTTP_HOST'];
?>

<a href="http://<?php echo $baseURL ?>">Home</a> | <a href="http://<?php echo $baseURL ?>/news">News</a> | (etc.)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.