Jump to content

Can I change the HTML directory pointer?


MrCat

Recommended Posts

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?

 

Link to comment
https://forums.phpfreaks.com/topic/235830-can-i-change-the-html-directory-pointer/
Share on other sites

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.

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 ../

 

 

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.

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.