Best practice for making code portable for domains, subdomains or directores

Posted by Duopixel on Stack Overflow See other posts from Stack Overflow or by Duopixel
Published on 2010-12-31T18:44:42Z Indexed on 2010/12/31 19:54 UTC
Read the original article Hit count: 378

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:

  1. Use absolute paths (/css/styles.css) and modrewrite if it ends up being /user
  2. Have a settings file and declare a variable with the path (<? php echo $domain . "/css/styles" ?>)
  3. Use relative paths (../css/styles.css).

What is the best way to handle this?

© Stack Overflow or respective owner

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: 379

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:

  1. Use absolute paths (/css/styles.css) and modrewrite if it ends up being /user
  2. Have a settings file and declare a variable with the path (<? php echo $domain . "/css/styles" ?>)
  3. Use relative paths (../css/styles.css).

What is the best way to handle this?

© Server Fault or respective owner

Related posts about .htaccess

Related posts about subdomain