logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: virtualhost to only one directory
Author
phil1234



Joined: 24 Jul 2015
Posts: 11

PostPosted: Fri 24 Jul '15 16:29    Post subject: virtualhost to only one directory Reply with quote

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

PostPosted: Fri 24 Jul '15 18:12    Post subject: Reply with quote

Can you tell us where ExternalApp/index.php is located in /var/www ?
Back to top
phil1234



Joined: 24 Jul 2015
Posts: 11

PostPosted: Mon 27 Jul '15 9:02    Post subject: Reply with quote

in /var/www/ExternalApp
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Tue 28 Jul '15 11:04    Post subject: Reply with quote

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

PostPosted: Tue 28 Jul '15 13:29    Post subject: Reply with quote

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

PostPosted: Tue 28 Jul '15 13:41    Post subject: Reply with quote

You can Deny everything and allow by Location aka URL
Back to top


Reply to topic   Topic: virtualhost to only one directory View previous topic :: View next topic
Post new topic   Forum Index -> Apache