Configuring apache to deny traversing to seperate domains - apache

So, I have just found something I've missed about Apache ...
I have 3 sites:
/var/www/site1files (www.site1.com)
/var/www/site2files (www.site2.com)
/var/www/site3files (www.site3.com)
Each have an index.html ...
Now, when I go to each site, they work as expected ...
But, if I go to www.site1.com/site2files/index.html, strangely, it brings up that file (www.site2.com/index.html) ... Surely there's something really wrong I've done with my configuration ...
apache.conf (all default with):
<Directory /var/www/site1>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/site2>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/site3>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
And each has a conf file in enabled-sites:
<VirtualHost *:80>
ServerAdmin admin#site1.com
ServerName site1.com
ServerAlias www.site1.com
DirectoryIndex index.html
DocumentRoot /var/www/site1
<Directory /var/www/site1>
Options +FollowSymLinks -MultiViews -Indexes
AllowOverride None
Order allow,deny
allow from all
Require all granted
ErrorDocument 403 /404.php
ErrorDocument 404 /404.php
ErrorDocument 500 /500.php
</Directory>
</VirtualHost>

Okay, it seems I was confused about how to set up apache ...
I removed the site1,site2 and site3 <Directory> blocks from the apache.conf file, and just left the conf files in enabled sites ... Kinda makes sense now that I think about it ...
Remedial apache documentation reading for me ...

Related

apache httpd is automatically redirecting to https

Server is running on RHEL 7.9, httpd 2.4.6 and I have the following structure in my /var/www/html directory:
/site
index.php
I can reach the root index.php by visiting the IP address. However, when I try to access content inside /site directory, it automatically switches to https, hence the content does not load.
Some snippets from /etc/httpd/conf/httpd.conf:
DocumentRoot "/var/www/html"
<Directory />
AllowOverride None
Require all denied
Options -Indexes +FollowSymLinks
</Directory>
<Directory "/var/www/html">
AllowOverride All
Options -Indexes +FollowSymLinks
Require all granted
</Directory>
<Directory "/var/www/html">
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
AccessFileName .htaccess
<IfModule dir_module>
DirectoryIndex index.php index.htm index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
IncludeOptional conf.d/*.conf
I have a virtual host setup for /etc/httpd/conf.d/site.conf
<VirtualHost <server ip>:80>
ServerAdmin webmaster#sitename.com
DocumentRoot /var/www/html/site/
ServerName www.sitename.com
ServerAlias sitename
<Directory /var/www/html/site>
Require all granted
</Directory>
</VirtualHost>

configure apache to allow directory listing

Hi installed wordpress as localhost on my machine. I wanted to access it from another machine on my LAN. I can access the page. But non of the images or css is applying, Looking in firebug it's riddled with 404 errors to all the files it required. the path specifies the IP and not Localhost and exist in their locations.
I am trying to set apache to allow file browsing via the website I have set HTTPD.CONF and .htaccess but cant get file browsing the site is located at c:\xampp\apache\htdocs
heres what I have in httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
<Directory />
AllowOverride all
Require all granted
</Directory>
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
<Directory "/wordpress">
AllowOverride all
Require all granted
Options Indexes FollowSymLinks
</Directory>
<VirtualHost *:80>
DocumentRoot "c:/xampp/htdocs/wordpress/index.php"
ServerName wordpress
</VirtualHost>
in .htaccess
Options +Indexes
the error.log doesn't contain anything that stands out to me
You have to specify the option +Indexes in the corresponding Directory:
<Directory "C:/xampp/apache/htdocs">
Options +Indexes
</Directory>

Forbidden 403 error when running apache

I am trying to set up a rails app(redmine) on Ubuntu 14.10 running apache2.
log
Cannot server Directory: No matching DirectoryIndex
(index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found,
and server-generated directory index forbidden by Options directive
host.confg
<VirtualHost *:80>
ServerAdmin kanishka#thewolf.in
ServerName app.in
ServerAlias app.in
DocumentRoot /var/www/app.in/public_html/
ErrorLog /var/www/app.in/log/error.log
CustomLog /var/www/tribeapp.in/access.log combined
<Directory /var/www/app.in/public_html/redmine/public>
Options Indexes FollowSymLinks MultiViews
Require all granted
RailsBaseURI /redmine
PassengerResolveSymlinksInDocumentRoot on
Order allow,deny
allow from all
AllowOverride all
</Directory>
</VirtualHost>
New to rails. Let me know if you need more info.
Try this
Options All <--turn on all options
Options Indexes FollowSymLinks <--- replace previously set options with these two

.htaccess file can't find 404 ErrorDocument

The .htaccess file I have is unable to find my 404.html document in a sub-folder called "error". The line in particular is:
ErrorDocument 404 /error/404.html
However, if I place 404.html in the same directory as .htaccess and change the line to:
ErrorDocument 404 /404.html --- It works!
I'm using XAMPP for Windows if that helps, and in my httpd.conf file, the relevant directives are set as follows (I realize there is some redundancy):
<Directory />
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI MultiViews
AllowOverride All
Require all granted
</Directory>
Also, my DocumentRoot is set to "C:/xampp/htdocs", and I'v tried various paths to access the "error" directory--none work:
ErrorDocument 404 /error/404.html
ErrorDocument 404 /flchi/error/404.html
ErrorDocument 404 /sites/flchi/error/404.html
ErrorDocument 404 /htdocs/sites/flchi/error/404.html
Oh, and one final thing for what it's worth--I'm using virtual hosts. Here's the relevant bits:
<VirtualHost *>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
ServerAlias localhost
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost flchi.local>
DocumentRoot "C:/xampp/htdocs/sites/flchi"
ServerName flchi.local
ServerAlias flchi.local
<Directory "C:/xampp/htdocs/sites/flchi">
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
This happens because of naming conflict - default Apache configuration already defines virtual path for /error, affecting all virtual hosts globally. It's done in config file xampp/apache/conf/extra/httpd-multilang-errordoc.conf. Location /error, therefore shadows your /error subdirectory:
Alias /error/ "C:/xampp/apache/error/"
It should work if you rename your 'error' sub-directory to something else - for example, error2.
ErrorDocument 404 /error2/404.html

AllowOverride for .htaccess on local machine giving 403 Forbidden

I have a mod_rewrite I'd like to use locally on my mac but when I change my configuration to in my directory tag I get a 403 Forbidden error. I've tried all the other solutions around but no luck.
Maybe somebody will see something I am not...
Here is the code:
httpd.conf
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
<Directory "/Library/WebServer/Documents/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Which is overridden by myusername.conf
<Directory /Users/adrianmaurer/Sites/www>
Options Indexes MultiViews FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Virtual host file httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot /Library/WebServer/Documents
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /Users/adrianmaurer/Sites/www
ServerName myserver.dev
</VirtualHost>
I was able to get it fixed by setting my /etc/apache2/users/username.conf file like so (Note you have to change the Options line too, not just the AllowOverride):
<Directory "/Users/tlhunter/Sites/">
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>