MrCat Posted May 8, 2011 Share Posted May 8, 2011 I'm entering my site via a sub folder, e.g. mysite.com/BeginHere (which triggers index.php in the BeginHere folder) and then including my main page which is in the root folder. I change the directory pointer with chdir( '../' ) so now I'm officially back in the root folder. This works fine - but the HTML still points to one directory down. Is there any way I can move this up one level as well? Quote Link to comment https://forums.phpfreaks.com/topic/235830-can-i-change-the-html-directory-pointer/ Share on other sites More sharing options...
spiderwell Posted May 8, 2011 Share Posted May 8, 2011 im not quite sure i follow what you are saying. does beginhere/index.php, have an include folder thats located up one level? or does it redirect instead of include? the html points to one directory down - i have no idea what this means! Quote Link to comment https://forums.phpfreaks.com/topic/235830-can-i-change-the-html-directory-pointer/#findComment-1212259 Share on other sites More sharing options...
xyph Posted May 8, 2011 Share Posted May 8, 2011 PHP and HTML are independent of each other. PHP is code processed server-side. HTML is markup that is rendered on the client's computer. I think you want something similar to <base /> but for images. I don't think it exists. You COULD automate this with PHP, I suppose. Quote Link to comment https://forums.phpfreaks.com/topic/235830-can-i-change-the-html-directory-pointer/#findComment-1212264 Share on other sites More sharing options...
MrCat Posted May 8, 2011 Author Share Posted May 8, 2011 To try and clarify what I mean: I don't want my 'secret' site to exist through mysite.com I also want user accounts that are accessed simply by typing mysite.com/Username The index.php in mysite.com/Username doesn't redirect - it changes the PHP directory pointer up one level and then includes the 'main page' file which is in mysite.com Changing the directory pointer is simply so I don't have to start all subsequent links with ../ to reach files common to all accounts - mysite.com/images etc. The HTML directory however remains as mysite.com/Username so all links in HTML have to begin with ../ Quote Link to comment https://forums.phpfreaks.com/topic/235830-can-i-change-the-html-directory-pointer/#findComment-1212272 Share on other sites More sharing options...
spiderwell Posted May 8, 2011 Share Posted May 8, 2011 as stated, in html there is a base tag which is probably going to achieve what you want. read this to learn more Quote Link to comment https://forums.phpfreaks.com/topic/235830-can-i-change-the-html-directory-pointer/#findComment-1212274 Share on other sites More sharing options...
xyph Posted May 8, 2011 Share Posted May 8, 2011 Why not use the direct link? <img src="../images/somefile.jpg" /> rather <img src="http://mysite.com/images/somefile.jpg" /> Using the absolute paths in your script will prevent you from having to change the directory pointer completely, which is a very clumsy solution to your problem. Quote Link to comment https://forums.phpfreaks.com/topic/235830-can-i-change-the-html-directory-pointer/#findComment-1212277 Share on other sites More sharing options...
MrCat Posted May 8, 2011 Author Share Posted May 8, 2011 Thanks guys - the <base href> tag appears to be the solution I was looking for. Sorry I missed your suggestion xyph. I'd never heard of it and had to research it. All I was trying to do was to avoid ../ on every link if I enter my site at a level other than the root directory. Quote Link to comment https://forums.phpfreaks.com/topic/235830-can-i-change-the-html-directory-pointer/#findComment-1212281 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.