Jump to content

Recommended Posts

Hi there,

 

I am working on a website which has a sub-domain set as a folder and not an actual sub-domain (as my client does not want to do this which is another story). Anyway, all of my links which relate to the DOCUMENT_ROOT are not working. Example below:

 

www.website.com

 

www.website.com/admin - my sub-domain in a folder

 

I can access a page within www.website.com/admin however all links to files, css files etc will not work because the DOCUMENT_ROOT does not inlcude the /admin/.

 

My question is therefore is there some way of adding in this /admin/ step or fooling php/apache to include this in all files within the /admin/ folder.

 

Many thanks

Sim

In your main included file (usually config.php)  modify the DOCUMENT_ROOT for that folder, it's not like you cannot append to it...

 

$_SERVER['DOCUMENT_ROOT'] .= '/admin/';

 

Should do it, and as long as that config file is only used in that admin subdirectory, it should not affect the rest of the scripts.

Hi there,

 

I do apologise I may have explained it poorly. I have actuall got that installed already and that sorts out anywhere I have DOC_ROOT.

 

My issue is actually anywhere I have a path to a file e.g. /website.css or /website.js it will not reference correctly because it is going back a folder (hope that makes sense).

 

So I guess my question is can you change the .htaccess or apache to rewrite / to become /admin/???

 

Thanks (and sorry for the confusion)

 

Simon

For that you will most likely want to use the base tag, so inside the <head> tag of your html (hopefully it is templated and you have 1 header file or so to change) add the following before the </head>

 

<base href="http://www.somesite.com/admin/" />
</head>

 

And that should resolve that problem.

Hi there,

 

Just tried the base href tag and it didnt work unfortunately. To give some more information here:

 

- In my .htaccess i have a RewriteBase /admin <- i need this to actually get to the correct files as my structure is:

 

/ -> root files for front-facing website

/admin/ -> the admin is found within this folder and within here this is where i need to tweak/change the DOC ROOT

 

- In my header i need to somehow redirect any files from root to /admin/(root now here)

 

<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />

<link rel="stylesheet" type="text/css" href="/css/screen.css" media="screen" />

<link rel="stylesheet" type="text/css" href="/css/orange/orange.css" media="screen" />

 

So they would become:

 

<link rel="shortcut icon" href="/admin/favicon.ico" type="image/x-icon" />

<link rel="stylesheet" type="text/css" href="/admin/css/screen.css" media="screen" />

<link rel="stylesheet" type="text/css" href="/admin/css/orange/orange.css" media="screen" />

 

Thanks

Simon

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.