Hi.

Just recently has stopped working. All the urls on my site have gone haywire and therefore all links and files are not loading correctly.

I am using a CMS called skeleton which is really more of a very basic flat file templating tool.

One really useful feature is that I am able to use <?=$url->base?> in my html and the script will in turn replace it with . This means I don't have to change all the base urls for any of my links or files even if I move the site to another domain.

However just recently these links no longer display the correct url. Instead they are now displaying I believe the script that controls this is...

$url->base = 'http://' . $_SERVER['HTTP_HOST'] . str_replace($_SERVER['PHP_SELF'], '', ROOT);

Unfortunately I don't know much PHP and I can't work out what the script is doing and therefore cannot diagnose the problem. More so I don't understand why this has stopped working as I haven't made any changes to the files recently. I even have another site with this framework on the same host and it has stopped working too.

My host has not provided me with much help and it has been really frustrating as I know they have done something to trigger this yet they are reluctant to acknowledge that this might be the case.

Can anyone help me?

It might be worth mentioning that the framework also uses a .htaccess file which contains the following code...

Options +FollowSymLinks


	RewriteEngine on
	RewriteCond %{REQUEST_FILENAME} !-s
	Rewriterule (.*) index.php

I really appreciate your time in reading my post.

Dani AI

Generated

Short summary and likely root cause: the CMS builds an absolute base URL by combining the HTTP host with a path derived from the server filesystem. That replacement step will produce a wrong, filesystem-style URL when the server-provided path (the value used to strip off the document-root portion) no longer matches the actual working directory. As suggested, the .htaccess rewrite is unlikely to be the direct cause.

Immediate checks (fast and safe)

  • Use a temporary debug page (or phpinfo()) to compare the web-facing values: the current working directory and the various $_SERVER entries such as DOCUMENT_ROOT, SCRIPT_NAME, PHP_SELF, SCRIPT_FILENAME and HTTP_HOST. If DOCUMENT_ROOT does not match the prefix of the working directory, the string-replace step will leave the full filesystem path in place.
  • Ask the host whether they changed PHP handler, chroot/symlink setup, or vhost DocumentRoot during a migration — these commonly change those values.

Quick fixes and recommended approach

  • For a robust base URL, compute the web path from the script name (the URL-visible path) rather than relying on filesystem paths. This avoids depending on server internals that hosts sometimes change. Example pattern:
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
$host   = $_SERVER['HTTP_HOST'];
$base   = $scheme . '://' . $host . rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\') . '/';
  • If the host refuses to fix the server-side mismatch, set the base explicitly in a single config file or use relative URLs to avoid brittle, environment-dependent logic.

Notes and safety

It looks like that your $url->base value were replaced with project dir, not the project path, they are completely different, try to find somewhere in the code other possible assignemnts to $url->base.
I believe .htaccess has nothing to do with that.

Just noticed another piece of code at the top which looks important...

// THIS is the root directory
define('ROOT', getcwd());

// make some URL's
$url = new stdClass();
	$url->root = ROOT;
	$url->base = 'http://' . $_SERVER['HTTP_HOST'] . str_replace($_SERVER['DOCUMENT_ROOT'], '', ROOT);
	$url->theme = $url->base . '/theme';

getcwd() looks like this might be holding the document path or dir not sure of the difference. However I still don't understand how this in returning a different url to what it was a week ago. What could my host have done?

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.