changing document root for a website

Discussion in 'Apache' started by treemonster19, Aug 14, 2010.

  1. #1
    Hi friends,

    I am having a website under a subfolder pf apache web root directory "htdocs"

    htdocs/site1

    Now i am using php $_SERVER['REQUEST_URI'] function to get the request part of url, in this site for example if i enter
    http://localhost/site1/user/login

    I am getting /site1/user/login value for above variable but site1 is root for this site and might be different in different cases so i dont want this to be a part of of request uri

    For example some ppls might directly put the content inside site1 directory into root of their htdocs/ directory or in some cases they might rename it to say site2

    I dont want to create virtual host for this is there any way to do it via .htaccess or any other hope

    Hoping for urgent response.
    Thanks & regardss
    Abhishek
     
    treemonster19, Aug 14, 2010 IP
  2. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #2
    in your apache default configuration file, change the path to root for your site to include /site2/
    example
    in a common server environment, document root may often be

    /srv/www/htdocs

    if you want the actual files to be saved into first subfolder site1

    then that above apache configuration should rather be

    /srv/www/htdocs/site1/

    if you have multiple sites on same apache
    then accordingly you might have

    /srv/www/htdocs/site2/
    /srv/www/htdocs/site3/
    /srv/www/htdocs/sitex/

    this should result in your php $_SERVER['REQUEST_URI'] function being
    http://site1.tld/user/login
    http://site2.tld/user/login
    etc
     
    Last edited: Aug 15, 2010
    hans, Aug 15, 2010 IP
  3. treemonster19

    treemonster19 Member

    Messages:
    142
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    28
    #3
    thanks for the reply..but i am looking for my CMS to be distributed and shared hosting users should be able to install & run it without any configuration

    www.example.com/site1/
    or directly under
    www.example.com/
     
    treemonster19, Aug 15, 2010 IP