I have a strange behavior of apache. I have file test.php in virtual server root and it's opens by url: example.com/test.php, but if I try to open this url example.com/test.php/noexists.php I also see content of example.com/test.php file.
File noexists.php dosen't exists on server, but server doesn't return 404 error. How to get 404 error for non existing files?
Apache 2.2, virtual server config:
<VirtualHost *:80>
ServerAdmin info#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com
ErrorLog ${APACHE_LOG_DIR}/example.com.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/example.com.log combined
</VirtualHost>
" assume the location /test/ points to a directory that contains only
the single file here.html. Then requests for /test/here.html/more
and /test/nothere.html/more both collect /more as PATH_INFO "
[source]
That is the default behaviour. However you can change it by using this in your apache config files.
AcceptPathInfo Off
Related
I've
/var/www/app.mydomain.com
This contain only on index.html with
<h1>I want it works ... please</h1>
This is my /etc/apache2/sites-enabled/app-mydomain-com.conf
<VirtualHost *:80>
ServerName app.mydomain.com
ServerAdmin info#mydomain.it
DocumentRoot /var/www/app.mydomain.com
CustomLog ${APACHE_LOG_DIR}/vhosts/app-mydomain-com/access.log vhost_combined
ErrorLog ${APACHE_LOG_DIR}/vhosts/app-mydomain-com/error.log
</VirtualHost>
When I open browser at app.mydomain.com I got a forbidden from apache
In the error.log (the main error.log, NOT the one specific of my vhost) I got
Cannot serve directory /var/www/: 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
I totally have no idea of what does it mean in my case
I tried to add
DirectoryIndex index.html
But nothing changes (after a restart of apache2, of course)
I verified that site was enabled
a2ensite app-mydomain-com
Site app-mydomain-com already enabled
At the end, the problem was only a missing ServerAlias directive.
I created a virtual host for on my Apache 2.4 Websever but if I am trying to load the URL the path is sometimes wrong and I get an error back by unknown reason.
I have the domain "test.com"
and my sites-available/default looks like this:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/test/
ServerName test.com/
<Directory /var/www/test/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
</VirtualHost>
If I am calling now the URL
"http://www.test.com/" or "www.test.com"
everything is fine but if I try to load for example "test.com" the server redirects me to
"test.com/test/"
and gives me a 404 Error. I don't understand why it is redirecting me like that on some URLs.
Try removing the trailing slash
ServerName test.com/
DocumentRoot /var/www/test/
And change it to
ServerName test.com
DocumentRoot /var/www/test
Its redirecting you becuase the trailing slash is pointing to the test sub directory in the document root.
Since this is the only vhost config. The following is from the apache documentation
<VirtualHost *:80>
# This first-listed virtual host is also the default for *:80
ServerName www.example.com
ServerAlias example.com
DocumentRoot "/www/domain"
</VirtualHost>
Now all you have to do is add a server alias to specify www so that apache knows how to handle the event
I have deployed OwnCloud 8 on a Ubuntu 14.04 instance to the domain box.example.com. I would like to host some static html on the same VM and have apache point project.example.com to it at /var/www/html.
In apache the file /etc/apache2/conf-available/owncloud.conf was created by OwnCloud containing:
#I changed the first line as follows
##Alias /owncloud "/var/www/owncloud/" # commented out
Alias / "/var/www/owncloud/"
<Directory "/var/www/owncloud">
Options +FollowSymLinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/owncloud
SetEnv HTTP_HOME /var/www/owncloud
</Directory>
How can I add a new subdomain VM in apache so that I'll have two working sites: box.example.com (OwnCloud instance) and project.example.com (static html). So far with everything I have tried project loads the OwnCloud front-end and does not open the static html.
Do I need to touch /etc/hosts?
I will update with examples of things I am trying and outcomes.
You can add both virtualhost in the same file (after the first ) directive or create another file in /etc/apache2/sites-available/ . You can start from the existing default file and adapt the servername and directory where your "project" is, and any other directive as needed.
Beware, if you run Apache2.4, the files should be named anyname.conf, for instance box.example.com.conf
And don't forgot to reload your apache server after having enabled the site.
You also need to set-up your DNS, in a zone file, for both box.example.com and project.example.com to point to the IP of your server.
You could create virtual host config files like /etc/apache/sites-available/01-owncloud.
<VirtualHost *:80>
ServerName box.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/owncloud
<Directory /var/www/owncloud/>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/owncloud-error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/owncloud-access.log combined
Redirect 301 /.well-known/carddav /remote.php/carddav
Redirect 301 /.well-known/caldav /remote.php/caldav
</VirtualHost>
Then enable it with a2ensite 01-owncloud.
Don't forget to set NameVirtualHost *:80 somewhere in a conf. I used /etc/apache2/ports.conf.
I have an strange bug on my droplet on DigitalOcean vps.
I have set up all virtual hosts and config. I have my website located in two folders:
1 - /var/www/mysite.com/public_html
2 - /var/www/html/mysite
I have created a etc/apache2/sites-available/mysite.com.conf with the following config:
<VirtualHost *:80>
ServerAdmin admin#mysite.com
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot /var/www/mysite.com/public_html/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
My ip is 111.111.111.111
So, when I go to mysite.com in my browser, instead of running index.php in /var/www/mysite.com/public_html folder it get redirected to my IP address and runs index.html file in /var/www/html folder.
If I put absolutely another index.html file in my /var/www/mysite.com/public_html and run it, it work perfectly.
I though that there was some problem with PHP. But I have a copy of my website in /var/www/html/mysite folder. So when I go to 111.111.111.111/mysite it runs the index.php file and the site works perfectly.
So, what is up with apache? Where is the problem?
I'm having some problems with setting up a VirtualHost with Apache on CentOS. I'll try my best to explain what happens.
In our httpd.conf file we had to change the Document root, our base is /var/www/mydomain.com but our files is on /var/www/mydomain.com/store2 and when users goto mydomain.com we want them to come directly to mydomain.com/store2
Main config:
DocumentRoot "/var/www/mydomain.com/store2/"
Directory "/var/www/mydomain.com/store2"
So, I've added an config file inside conf.d named subdomains.conf and this is the information inside
<VirtualHost *:80>
ServerAdmin mail#me.com
DocumentRoot /var/www/mydomain.com/subdomain
ServerName subdomain.mydomain.com
ErrorLog logs/subdomain.mydomain.com
CustomLog logs/subdomain.mydomain.com common
</VirtualHost>
When i restart the httpd service and goto mydomain.com I'm transferred to the virtual host root (/var/www/mydomain.com/subdomain) this also happens when i go to subdomain.mydomain.com. Is there something that I'm missing here? Could there be something with the DNS also? I see that mydomain.com and subdomain.mydomain.com points to the same IP-address.