directory slashes

Soldato
Joined
12 May 2007
Posts
3,896
Location
Bristol
Having a bit of a tricky one here.

We've just inherited a bunch of sites from a client. The urls throughout the sites use / to jump to root which is normal enough. They've done this because the .master is in root and the actual pages are in various folders and other than hardcoding the css url in for example, it's the only way to get it to work regardless of page url.

This works fine when the site is live. However, when it's on staging, the url changes from sitename.com to staging.oursite.co.uk/sitename. Now, those slashes jump to the root of our site as they should. Obviously, this means nothing (in particular, images and the main css file) points to where it should.

Anyone know if there is a way to control the depth the / jumps to?

This is on windows server.
 
I don't think so. '/' is treated as a default constant meaning site root. Same as '~' in ASPX. Maybe the server admin for the staging server could use an alias URL to point to the root folder?

Where I used to work, our internal staging server used sub domaining for client sites. Thats so the structure cloned the live server.

Client 1 was client1.ourcompany.com
Clinet 2 was client2.ourcompany.com

and so on.
 
Use "../" instead of "/". It will send you up just one level as opposed to sending you to the root.

Thats ok in some instances, but becomes a nightmare when working with templates or you decide to move files about your structure.

Also, I think '../' can be enabled or disabled on IIS per site basis.
 
You just stack them. Whilst it'll mean a lot of editing to start with, it will then make that site folder fully independent of its directory location. I use this as my preferred method since it makes the transition between dev and live stages very easy.
 
If using apache...

Setup a vhost, then proxy-redirect everything with:
Code:
ProxyRequests Off
ProxyPreserveHost On

<VirtualHost *:80>
  ServerName subhost.yoursite.com
  <Location /sitename>
        ProxyPass !
  </Location>
  <Location />
        ProxyPass http://127.0.0.1/sitename/
        ProxyPassReverse http://127.0.0.1/sitename/
  </Location>
</VirtualHost>

or..

Code:
<VirtualHost *:80>
  ServerName sitename.yoursite.com
  DocumentRoot /var/www/htdocs/sitename
</Virtualhost>
 
Last edited:
i remember asking a similar question a long time ago and someone mentioned putting all the include files into the include folder so that whever your location is, if you ask for file.php if it's not in the current folder then php or whatever will check the include folder for file.php.

perhaps not the answer you're looking for but i got the impression this was how it was supposed to be done when including files from different locations.

when i say include folder, i'm not sure what the folder is but it's definded in phpinfo() or howver it is written

i haven't done any php is far far far too long :(
 
Inside the <head>:

Code:
<base href="http://staging.oursite.co.uk/sitename" />

Simples. (Assuming the site uses a single header template!)
 
Last edited:
Sorry - I was thinking of the paths to the included files. If those also begin with a slash then might that not cause problems?

I understand. I always use a root slash '/xx' when referencing an include. Due to the fact that IIS has security setting options that can disable the use of "../" relative paths.

TBH I always just use the root slash for everything as I often find myself copy and pasting sections from 1 place to another, or moving files around.
 
I understand. I always use a root slash '/xx' when referencing an include. Due to the fact that IIS has security setting options that can disable the use of "../" relative paths.

TBH I always just use the root slash for everything as I often find myself copy and pasting sections from 1 place to another, or moving files around.

what do you do then when it's on your pc and when it's online? /xx works fine online but on my pc it goes to localhost, and the files can be in localhost/website1/design3/ etc
 
what do you do then when it's on your pc and when it's online? /xx works fine online but on my pc it goes to localhost, and the files can be in localhost/website1/design3/ etc

Im currently using windows 7. So win 7 supports multiple sites under IIS. I generally just make a new alias in the hosts file and map it to a host header in the site settings.

Where I used to work, if the designers were doing multiple design prototypes. They'd photoshop them until the client was happy. Then that photoshop prototype would be broken down into HTML.

If we ever did have a site running 2 designs for some reason. They were all given seperate aliases. So the web structure remained the same. It makes like much easier for us web programmers.
 
Back
Top Bottom