Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello,

I've a website (suppose mysite.com).
When I use relative paths in the directory (mysite.com/part1/) they work perfect. But when I use them on subdomain (part1.mysite.com), then point to part1.mysite.com

I mean when I use "../images/", they don't point to "mysite.com/images", they point to "part1.mysite.com/images". AND "part1.mysite.com" is only the url subdomain for "mysite.com/part1/"

Please don't tell me I shouldn't use relative paths, because I have to, for that I'm using PHP glob() function.

Appreciated!
Thanks!
Posted

1 solution

If you are asking the question, please don't tell us what we tell you and what not. Nothing can help you because you fail to follow very simple logic.

Of course you should use relative path, but in case of a different sub-domain, the relative path is simply equivalent to the full paths, because the top level of the hierarchy is already different.

As you apparently don't understand sub-domains, let me give you an example of Window paths. If your working directory is "d:/applications/myApplication/", what would be the relative path to "c:/applications"? Of course, "c:/applications". The level of the sub-domain in lower then the level of the main domain "mysite" but higher then anything in the path name.

In terms of URI scheme, on top of the "path" portion of the URI, there is an "authority" part on the left of it, and this authority part altogether (which includes "hostname" part which contains all part of domain names with all level of sub-domains) is always higher in hierarchy than the path part. Please see:
http://en.wikipedia.org/wiki/URI_scheme#Examples[^].

[EDIT]

You may want to consider URL rewriting or URL redirection. Please see:
http://en.wikipedia.org/wiki/URL_redirection[^],
(pay attention for: http://en.wikipedia.org/wiki/URL_redirection#Using_server-side_scripting_for_redirection[^]),
http://en.wikipedia.org/wiki/URL_rewriting[^],
http://www.addedbytes.com/for-beginners/url-rewriting-for-beginners/[^].

With PHP, you can use http_redirect. Please see:
http://www.devshed.com/c/a/PHP/How-to-Redirect-URLs-in-PHP/[^],
http://php.net/manual/en/function.http-redirect.php[^],
http://php.net/manual/en/function.header.php[^].

On URL re-writing with PHP, please see:
http://www.cyberdesignz.com/blog/website-design/url-rewriting-top-5-ways-of-php-url-rewriting/[^].

—SA
 
Share this answer
 
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900