...

View Full Version : set document root in shared hosting?



likon
03-27-2009, 12:43 AM
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

oesxyl
03-27-2009, 02:11 AM
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/reserved.variables.server.php

best regards

likon
03-27-2009, 03:13 AM
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 ?

oesxyl
03-27-2009, 03:30 AM
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/core.html#documentroot

What avantages you have if you change the default settings?

best regards

likon
03-27-2009, 03:36 AM
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

oesxyl
03-27-2009, 03:50 AM
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

likon
03-27-2009, 03:56 AM
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

oesxyl
03-27-2009, 04:18 AM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum