How to change the default webpage path for Apache2 in Ubuntu

* Initially you will need to create a new directory where you want Apache to point to for its default web content. The original default path is located in “/var/www/apache2-default”, so we want our new default directory to be “NEW-DIRECTORY-NAME” (for tutorial sake). Also make sure there is a valid index.html file inside the directory to test the new default path.
* Go to “/etc/apache2/sites-available/”, the “default” text file is what you will need to edit.
* So go ahead and make your backup of the default text file in. (e.g. default.bak)
* Now edit the directory path, which is about 17 lines down from the top.

This is what you should see for the path list information:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
RedirectMatch ^/$ /NEW-DIRECTORY-NAME/
</Directory>

* All you need to do now is STOP and then RE-START the Apache2 web service.
To do this open up your console and login as root (or you can ’su’ to root).
* Change your directory to “/etc/init.d/”
-Now STOP the apache service by using the command: apache2 -k stop
-Now START the apache service by using the command: apache2 -k start
* Your default web content directory should now be “NEW-DIRECTORY-NAME” (or what ever you want to called it).

Tags: , ,

5 Responses to “How to change the default webpage path for Apache2 in Ubuntu”

  1. John Chee Says:

    This helped a lot! It should be noted that just hashing out the RedirectMatch line will make it default to /var/www.

  2. blake Says:

    that is a good point. If you don?t want to redirect, then just delete the redirect line.

  3. Pavan Says:

    Thanks, it was informative!

  4. bill Says:

    that was really helpfull

  5. hari779 Says:

    Hi Blake,

    thanks. your information about was informative. But I have some doubts which I will post to you further reply.

    regards

    hari

Leave a Reply