Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Posts
    141
    Thanks
    3
    Thanked 1 Time in 1 Post

    set document root in shared hosting?

    is there anyway we can set the document root in shared hosting using htaccess or something?

    i knew document root was in http.conf apache if not mistaken . . and ( well i should have asked my hosting provider first ) but just wondering

    how do you guys set document roots in a shared hosting assuming the shared hosting does not give you much access as you could have in localhost


    thanks for the info..

    David

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    usualy you don't need to set in a way or another document root, I talk about web design, and it's enought to know the path. I use $_SERVER['DOCUMENT_ROOT'] for that.

    http://www.php.net/manual/en/reserve...les.server.php

    best regards

  • #3
    Regular Coder
    Join Date
    Apr 2007
    Posts
    141
    Thanks
    3
    Thanked 1 Time in 1 Post
    no its not about knowing the document root but how to set your document root on apache server on shared hosting.


    for example by default website load index.php index.html or whatever you define in www/

    i dont want it to load in www/

    but i want it to load whatever in www/public

    things like that.

    i could change it in httpd.conf in my local website.

    can we change it using htaccess or something on shared hosting assuming shared hosting does not give us much access ?

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by likon View Post
    no its not about knowing the document root but how to set your document root on apache server on shared hosting.


    for example by default website load index.php index.html or whatever you define in www/

    i dont want it to load in www/

    but i want it to load whatever in www/public

    things like that.

    i could change it in httpd.conf in my local website.

    can we change it using htaccess or something on shared hosting assuming shared hosting does not give us much access ?
    no, only from conf. It's not same thing but you can use mod_rewrite.

    http://httpd.apache.org/docs/2.2/mod...l#documentroot

    What avantages you have if you change the default settings?

    best regards

  • #5
    Regular Coder
    Join Date
    Apr 2007
    Posts
    141
    Thanks
    3
    Thanked 1 Time in 1 Post
    the advantage is well zend said it is better to put your application / important file outside of the "public folder" and only the web app that can access it. not from somewhere elese


    www/
    www/sensitive/ files.
    www/public/ not important data ; and access www/sensitive/ something


    can we do that *cry cry* hehehhe

  • #6
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by likon View Post
    the advantage is well zend said it is better to put your application / important file outside of the "public folder" and only the web app that can access it. not from somewhere elese


    www/
    www/sensitive/ files.
    www/public/ not important data ; and access www/sensitive/ something


    can we do that *cry cry* hehehhe
    www/sensitive/ and www/public/ are outside the public folder. Changing document root from www to pepe/le/piu/ don't change anything.

    best regards

  • #7
    Regular Coder
    Join Date
    Apr 2007
    Posts
    141
    Thanks
    3
    Thanked 1 Time in 1 Post
    oops sorry forgot do mention

    if we set DocumentRoot to

    www/public/
    then website will try to load

    www/public/index.htm or index.php or whatever.

    people generally wont be able to access

    www/notpublic/sensitive.



    and the way we access
    www/notpublic/sensitive.

    is by

    www/public/ourownapplicationthatcanaccesswwwnotpublicsensitive.php


    but how do we do that on shared hosting ?

    thanks

  • #8
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by likon View Post
    oops sorry forgot do mention

    if we set DocumentRoot to

    www/public/
    then website will try to load

    www/public/index.htm or index.php or whatever.

    people generally wont be able to access

    www/notpublic/sensitive.



    and the way we access
    www/notpublic/sensitive.

    is by

    www/public/ourownapplicationthatcanaccesswwwnotpublicsensitive.php


    but how do we do that on shared hosting ?

    thanks
    if you use $_SERVER['DOCUMENT_ROOT'] you can build absolute path of a place on your server if you know the relative path of that place. That's not depend of where is document root.
    this way a relative path like "../notpublic/sensitive/whatever" in "ourownapplicationthatcanaccesswwwnotpublicsensitive.php" will point to "whatever".
    Same way you can use document root env variable to build the absolute path.
    If you move your work from one server to another and keep same directory tree you don't need to change anything regarding file location if you use relative path to the document root.

    afaik share hosting have nothing special regarding this problem.

    best regards


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •