Jump to content

Recommended Posts

Hi,

 

I'm making a move from html to php and have come accross a couple of issues.... the main one I have is refrencing some files. Normally I would use....

 

<head>
<base href="http://letscommunicate.co.uk">
</head> 

at the top of each page how ever my php pages ( some where written by another person have have been proven to work ) dont like them and error.

 

I did find a more advance version on the net which is as follows and I'd perfer to use.

 

<head>
<base href="http://<?php 
if(($_SERVER['HTTP_HOST'])=='localhost'){ echo'localhost/'; } 
else { echo'www.traffic.letscommunicate.co.uk/'; } 
echo $_SERVER['REQUEST_URI'] 
?>" /> 
</head>

 

Some of the php pages will be called by a CRON job so I guess the html commands will be of no use so I've got to find a 'pure' php equivelent.

 

The reason I beleive I need to do this is because I think by using '/folder/file.ext' its going to the root of the virtual server of my host rather than the root of my domain.

 

Any advice or suggestions would be much apprciated as I have to apply this against all my pages so looking for an easy way to do it.... may be a config.php file some where which I can include ???? ( not sure how to do that just read some thing some where ).

 

Thanks

 

Terran

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/66185-base-href-and-a-pure-php-equiv/
Share on other sites

I've found some info here ( http://uk3.php.net/reserved.variables ) which I'll have to go through but just to check... is $_SERVER['DOCUMENT_ROOT']. A read only command... or could I use it as in....

 

require("$_SERVER/includes/db.inc.php");

 

? ( Its the /includes/db.inc.php file I'm having probs with seeing due to I think it looking at the 'server' root and not the domain root. )

 

Terran

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.