Best practice for making code portable for domains, subdomains or directores
Posted
by
Duopixel
on Server Fault
See other posts from Server Fault
or by Duopixel
Published on 2010-12-31T18:44:42Z
Indexed on
2010/12/31
18:55 UTC
Read the original article
Hit count: 413
I recently coded something where it wasn't known if the end code would reside in a subdomain (http://user.domain.com/) or in a subdomain (http://domain.com/user), and I was lost as to the best practice for these unknown scenarios. I could thinks of a couple:
- Use absolute paths (/css/styles.css) and modrewrite if it ends up being /user
- Have a settings file and declare a variable with the path (<? php echo $domain . "/css/styles" ?>)
- Use relative paths (../css/styles.css).
What is the best way to handle this?
© Server Fault or respective owner