On 30-09-2012 14:21, Tom Sparks wrote:
  I have created a php script that use $_SERVER['PATH_INFO'], for the different 
sub-sections
the links now looks like this 
http://localhost/collection/popups.php/models/bttf/car01/


  my web browser cant load my images/javascripts/etc because it is trying to use
  relative url from http://localhost/collection/popups.php/models/bttf/car01/*
  witch is incorrect, but the browser gets a 200 (ok) message from the server

my images/javascripst/etc is relative to http://localhost/collection/*
but my requirement dictate relative url only because I may move the folder
later to a new location

what are my options?

  ---
tom_a_sparks "It's a nerdy thing I like to do"


I don't know where you store your images, scripts, etc. but I would hazard in a different dir. What you could do is check if the path request you recieve includes those dirs. If so, send a permanent redirect to the browser with the correct url. Ie. an error 301 Moved Permanently.

Alternatively, what I prefer. Is to have your paths stored in a variable, and to simply output that variable's contents as the base-path. This way, you can still show things relative to that base-path, and when you move the folder, you only need to update that one variable (which should be in a config file somewhere).

In other words:
instead of saying "go to /absolute/path/to/foo/images/whatever.jpg" or "./images/whatever.jpg" you do a:
$BASE_PATH = '/absolute/oath/to/foo';
echo $BASE_PATH . '/images/whatever.jpg';

In other words, you're combining the power of relative paths with that of absolute ones.

- Tul

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to