apache alias error subfolders access - apache

I have WAMP server 2.2
I created a test php project (2 php files) in my test folder, the test folder is located at: c:\projects\test\
I added an alias to apache, and the conf file is this:
Alias /test "c:\projects\test\"
<Directory "c:\projects\test/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>
I added a new folder under test, full path is: c:\projects\test\img
My issue is that I cannot access from http any file located under this folder. Do I have to add some extra line in conf file? What is wrong? I'd like to be able to access any file in any subfolder of my root folder (c:\projects\test).
Thank you.

Related

How to hide everything but public folder(s) having multiple laravel projects ? (apache)

I have multiple laravel projects in my htdocs folder:
htdocs/laravelProjectA
and
htdocs/laravelProjectB
So that if i want to access a laravel route of lets say laravelProjectA the corresponding url will be:
localhost/laravelProjectA/public/myRoute
The problem is that all the laravel files and folders are inside the htdocs folder and therefore accessible to the Web, meaning that i can enter, for example:
localhost/laravelProjectA/.env
and view all the sensible data.
How can I hide all the files and folders but the public folder from each project using Apache? So that localhost/laravelProjetA/.env, localhost/laravelProjectA/.gitignore, and every request for the other files result in a 404 error, or similar.
I know i can leave only the public folder inside the htdocs folder for each project and move the other files and folders somewhere else and then change the public/index.php file, but I want to use apache to hide those files in order to have each project in a single directory.
You have to edit the /etc/apache2/apache2.conf
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
to
<Directory /var/www/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Server will stop showing files

How to create an Alias in Apache to a network shared directory?

I'm running Apache 2.2 (on OS 10.9 Mavericks) and have a directory on my NAS (My Cloud EX2100) that I would like to set up with as an aliased web site.
To do so, I've created a .conf file (I called it aliases.conf) in /private/etc/apache2/other (Note that the httpd.conf has Include /private/etc/apache2/other/*.conf added to it).
In my aliases.conf I have
Alias /foo /Volumes/bar/
<Directory "/Volumes/bar">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
I then restart apache and open a browser to go to http://localhost/foo, but I get the error message
Forbidden
You don't have permission to access /foo on this server.
How do I give Apache access to the shared/aliased directory that is on the NAS?
Make sure that the apache user has read permissions to your NAS folder.
Furthermore switch the order of allow and deny to Order deny,allow
I don't know if you have any index files. But if you would like to browse through your directories you have to modify your options entry to: Options FollowSymLinks Idexes
Then restart your apache and try again.

Location and Directory cause 500 error

I have an .htacces file and I am trying to open up access to a file and folder within a protected folder.
The file is index.php so I do the following:
<Files index.php>
Order Allow,Deny
Allow from All
Satisfy Any
</Files>
This works and give me access to this file. This file requires assets from the assets/ directory. So I try to open that directory up by doing the following:
<Directory "/assets">
Order Allow,Deny
Allow from All
Satisfy Any
</Directory>
But this is giving me a 500 error. Not sure why.
You can't use the <Directory> container inside an htaccess file (which is essentially like the <Directory> container itself). If you want to allow access to assets, then create an htaccess file inassets with just:
Order Allow,Deny
Allow from All

Configure Apache Directories

I have a problem in configuring my Apache. This litte indian is something headstrong.
My Application is located under /var/www/myapp/
There are 3 Elements:
./index.cgi - a python cgi script correctly working
./Application/ - a directory, which should be not public. contains include packages for index.cgi
./Public/ - a directory, public. contains javascripts, css files, images e.q.
My current VirtualHost configuration looks like:
DocumentRoot /var/www/myapp/
Alias /Public/* "/var/www/myapp/Public/*"
<Location "/myapp/*">
Options FollowSymLinks
Order allow,deny
Allow from all
</Location>
ScriptAlias "/index.cgi" "/var/www/myapp/index.cgi"
So /Public is public as wished, index.cgi runs. But: /Application is accessible. How do I lock this directory?
Second thing is: index.cgi should run, when I call www.mydomain.com/ or www.mydomain.com/index.cgi. Nothing else but URI parameters. How do I do that?
Thanks in advance,
BigM
You can verify the permissions in the files, but I think that the problem is that you don't have an alias for the Application folder in your Apache Configuration File.

How to allow files to be accessed by scripts but not the internet - Apache

I wish to set up an apache server running php. I want all the files in a particular folder (say /site/ ) to be accessible from www.example.com/ . However I wish the files in /site/data/ to be not visible through www.example.com/data/ . I want www.example.com/fun.php script to be able to read/write to /site/data/ . What is the best way to do this through premissions and the apache defalt file?
You need to set up your directory structure slightly differently to what you have proposed. Rather run your site under a directory like:
/site/html
and store your data under a directory like:
/site/data
configuring Apache to only serve files from /site/html and not /site/data
or if you are using a more traditional apache directory structure then put the files you want publicly accessible through the web server in:
/var/www/html
and the private data files you only want your application to have access to in something like:
/var/www/data
Your Apache conf file will then contain something like:
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
This way the files in /var/www/data will not be publicly accessible but these files can still be accessed by php scripts in /var/www/html/
Disable Apache directory listings by putting this in your .htaccess file under /site/data
Options -Indexes