simboski19 Posted December 2, 2011 Share Posted December 2, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/252316-sub-domain-work-around-for-document_root/ Share on other sites More sharing options...
premiso Posted December 2, 2011 Share Posted December 2, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/252316-sub-domain-work-around-for-document_root/#findComment-1293518 Share on other sites More sharing options...
simboski19 Posted December 2, 2011 Author Share Posted December 2, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/252316-sub-domain-work-around-for-document_root/#findComment-1293522 Share on other sites More sharing options...
premiso Posted December 2, 2011 Share Posted December 2, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/252316-sub-domain-work-around-for-document_root/#findComment-1293526 Share on other sites More sharing options...
simboski19 Posted December 5, 2011 Author Share Posted December 5, 2011 Thanks premiso. I havent heard of that tag so i will give it a go now and let you know how i get on. Many thanks Simon Quote Link to comment https://forums.phpfreaks.com/topic/252316-sub-domain-work-around-for-document_root/#findComment-1294520 Share on other sites More sharing options...
simboski19 Posted December 5, 2011 Author Share Posted December 5, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/252316-sub-domain-work-around-for-document_root/#findComment-1294522 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.