Document root outside htdocs (apache vhosts)

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Document root outside htdocs (apache vhosts)

Postby appyape » 14. September 2014 22:51

Hello

I have installed Xampp and edited httpd-vhosts.conf file to make changes for virtual hosts. I put this entry in the file ...

Code: Select all
<VirtualHost *:80>
    ServerAdmin myname@mymail.com
    DocumentRoot "C:/xampp1.8.2/htdocs"
    ServerName localhost
</VirtualHost>


and then I could access http://localhost homepage without any issues.

Now I moved the projects directory outside Xampp folder and specified virtual host as shown below ...

Code: Select all
<VirtualHost *:80>
    ServerAdmin myname@mymail.com
    DocumentRoot "C:/myprojects/project1php5.3"
    ServerName local.myproject1
</VirtualHost>


when I go to local.myproject1 url, I get access forbidden error (error 403) ... Am I doing it wrong way?

What i am trying to achieve here is to keep all the projects in a common directory outside Xampp folder ( I am using different Xampp version for different php versions depending upon which project I am working on) ...it looks something like this ...
Code: Select all
C:/xampp1.8.2
C:/xampp1.7.7
C:/myprojects
C:/myprojects/project1php5.3
C:/myprojects/project2php5.4

Just to make it clear, please note, I use one version of xampp at a time and both versions work fine individually. Can you please advise what changes do I need to make in httpd-vhosts.conf in both versions of xampp to be able to access my projects?

thanks
appyape
 
Posts: 9
Joined: 13. September 2014 12:57
Operating System: Windows

Re: Document root outside htdocs (apache vhosts)

Postby Altrea » 15. September 2014 06:30

Hi appyape,

You need to define Access rules for folders outside of htdocs, like so:
Code: Select all
<VirtualHost *:80>
    ServerAdmin myname@mymail.com
    DocumentRoot "C:/myprojects/project1php5.3"
    ServerName local.myproject1
    <Directory "C:/myprojects/project1php5.3">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>


The reason you don't need to do this for folders inside htdocs is that there is already a default rule defined for htdocs which gets inherited.

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Document root outside htdocs (apache vhosts)

Postby appyape » 15. September 2014 08:59

Excellent!! All working fine now. You are a star!! :)
appyape
 
Posts: 9
Joined: 13. September 2014 12:57
Operating System: Windows


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 82 guests