Author |
|
phil1234
Joined: 24 Jul 2015 Posts: 11
|
Posted: Fri 24 Jul '15 16:29 Post subject: virtualhost to only one directory |
|
|
hello,
I have set a virtualhost to the root of /var/www
because if I set it to a subfolder where my app is located, then the app does not find its js/css/images anymore
but as there are other dirs in /var/www, I only want to allow access to /ExternalApp/index.php for that virtual host
is it possible ?
//--------------------------- main site
<VirtualHost *:80>
ServerName www.mysite.com
ServerAlias mysite.com
DocumentRoot /var/www/mysite/
</VirtualHost>
//---------------------------- external app
<VirtualHost *:80>
ServerName externalapp.mysite.com
DocumentRoot /var/www/ <---- need this otherwise I get 404s
<Directory /ExternalApp>
Order Deny,Allow
Allow from All
</Directory>
<Directory />
Order Deny,Allow
Deny from All
</Directory>
</VirtualHost>
I use apache2
thanks |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Fri 24 Jul '15 18:12 Post subject: |
|
|
Can you tell us where ExternalApp/index.php is located in /var/www ? |
|
Back to top |
|
phil1234
Joined: 24 Jul 2015 Posts: 11
|
Posted: Mon 27 Jul '15 9:02 Post subject: |
|
|
in /var/www/ExternalApp |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Tue 28 Jul '15 11:04 Post subject: |
|
|
The easiest solution would be to put an empty index files in the /var/www directory. If you want to disallow that by config you would have to create rules for each sub folder that shall be allowed. |
|
Back to top |
|
phil1234
Joined: 24 Jul 2015 Posts: 11
|
Posted: Tue 28 Jul '15 13:29 Post subject: |
|
|
so I create a .htaccess file in each subfolder
but is there a way to only allow one or two files to be acessed ?
/SomeApp/index.php
/SomeApp/data.php |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Tue 28 Jul '15 13:41 Post subject: |
|
|
You can Deny everything and allow by Location aka URL |
|
Back to top |
|