I recently enabled ssl in apache2 and everything was going well, but now everytime I try to access http://example.com/ I get redirected to https://example.com/
I checked my default.conf, apache2.conf for some directions but didn't find any.
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName example.de
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
DocumentRoot /var/www
ServerName example.com
SSLEngine on
SSLCertificateFile /root/server.crt
SSLCertificateKeyFile /root/server.key
</VirtualHost>
I also double checked the .htaccess files in all directorys.
Is there a way to look up from where or what is redirecting?
Are any other ways to redirect ALL http requests to https?
Open Chrome Developer Tools, go to the network tab, click on preserve log, and load your site over http.
If you see a 301 or 302 redirect to https then something on the server is telling your browser to go to https.
If you see a 307 redirect to gyros then the site has, or had, a Strict-Transport-Security (aka HSTS) header set on it to force https and Chrome has cached that policy. This is a security feature web servers can use to enforce https. Check the HTTP Headers returned to see if that's the case and, if no such header is being sent than you can view and clear an old policy by using this page into your address bar: chrome://net-internals/#hsts
Related
I'm using Google VM instances on Google Cloud Platform for running my live server. I'm also using CodeIgniter to build of my server. It can load the default route when entering the page but when going to other routes, it shows Apache 404 error:
Not Found
The requested URL was not found on this server.
Apache/2.4.29 (Ubuntu) Server at 35.186.147.249 Port 80
My Apache config file at /etc/apache2/sites-available:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
I looked up online and most people say it is an Apache problem but I'm not too sure. I'll share any of the files in order to fix this issue.
The line DocumentRoot /var/www/html determinate the base of your files, I reviewed the IP that you put and i can see the next folder and access correctly:
j/
medical-survey/
temp/
Here is the link to understand more about DocumentRoot, so you can define where you require the default folder route for your web files. In case you require to have different links of your web development you can follow this link to configure the virtual hosts. Hope this is what you were looking for.
AS the title says, my rewrite rules does not work when I upload it to my server (Ubuntu LTS). The .htaccess-file is in play, but does nothing.
mod_rewrite is loaded, I've verified that several ways. I tried writing rubbish text in the .htaccess file and got a 500 internal error, so the file seems to be in the loop. The virtualHost configuration has "allowOverride All".
The .htaccess file consists of a series of rewrite rules, such as:
RewriteRule ^webshop$ index.php?page=webshop [QSA]
RewriteRule ^webshop/([0-9]+)$ index.php?page=webshop&catID=$1 [QSA]
On the server I have to virtualhosts, one public server and one testing server. The public server works fine, all rewriterules are similar to above and works. It's the virtualhost for testing that doesn't want to play. One server, one IP, two FQDNs.
Ideas?
EDIT - Here's the VirtualHost config:
<VirtualHost *:80>
ServerAdmin beta#example.com
ServerName beta.example.com
DocumentRoot /var/www/beta/www-root
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/beta/www-root>
AddDefaultCharset utf-8
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from (Two IPs omitted)
</Directory>
<Directory /var/www/temp>
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.beta.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
The problem seems to be that there is a folder with the same name as (a part of) the regex. I have a file called "webshop.php", and for some reason the regex ^webshop$ then fails (servers seems to prefer the actual folder/files rather than a local rewrite).
i have a domain name called for example "mydomain.com"
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options -Indexes FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options -Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
....
</VirtualHost>
When i write the following address in url:
www.mydomain.com/mysubdomain/myfolder
go to a web page working fine.
mysubdomain sites-available is the following, called mysubdomain
<VirtualHost *:80>
DocumentRoot /var/www/mysubdomain
ServerName www.mysubdomain.com
ServerAlias mysubdomain.com
ErrorLog ${APACHE_LOG_DIR}/error_mysubdomain.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access_mysubdomain.log combined
<Directory /var/www/mysubdomain>
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Everything works fine, when i type www.mydomain.com/mysubdomain/myfolder goes fine to
www.mydomain.com/mysubdomain/myfolder/login.php
but when i write
http://www.mysubdomain.com/myfolder/login.php
don´t work as expected, because when i include in login.php a ref, like ../../myfolder can´t go to root folder as i expected, how can i fix it ?
in www.mydomain.com/mysubdomain/myfolder/login.php the ref like ../../myfolder go fine to /var/www/
i want that the url showing to user could be http://www.mysubdomain.com/myfolder/login.php
Relative URLs are relative to the URL, not to the file system on the web server (which is invisible to the client).
You can't navigate up the directory tree to a file which doesn't appear under the web root for the virtual host being viewed.
The solution is simple:
change the file mysubdomain that is in sites-available to
DocumentRoot /var/www/mysubdomain
ServerName www.mysubdomain.com
ServerAlias mysubdomain.com
ErrorLog ${APACHE_LOG_DIR}/error_mysubdomain.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access_mysubdomain.log combined
Alias /myfolder /var/www/myfolder
<Directory /var/www/mysubdomain>
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
I am using Ubunto.When i browse my local host i would like to see my shared directory named myproj. now when i browse it ,this is the message i receive:
Forbidden
You don't have permission to access / on this server.
I tried:
1)giving permission to anyone on this directory and changed the owner to my current user
2) changed my conf settings to below:
Can anyone help me fixing this?
my conf settings is as below:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /etc/apache2/sites-available/myproj
<Directory /myproj>
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /etc/apache2/sites-available/myproj>
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
deny None
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
In the conf you should change:
-Indexes
To:
Indexes
Then, after restarting Apache and provided that /etc/apache2/sites-available/myproj does not have an index.html or index.php as default document you can see the contents of that folder displayed in your browser.
I have a problem with mod_rewrite and I cannot understand what is wrong.
First I did a query string rewrite to have something like this:
/api/call
instead of
/api.php/call.php
This did not work as when printing the request, it was empty, whereas if I enter the url
/api/call/test=5
the request parameters returns with test=5
I added the Allow from all in the virtual host but it still did not work.
I then tried to disable mod_rewrite and to my amazement the call /api still loaded /api.php and /index loaded /index.html.
This is really strange as this is not supposed to happen if mod_rewrite is disabled. In fact, if I try it on my local WAMP server, a 404 not found is shown.
This means that somewhere there is some sort of rewrite on the Ubuntu server but I cannot understand how this is working with mod_rewrite being disabled.
Any ideas?
Thanks in advance
EDIT (sites-available contents)
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
Apache was restarted successfully with restart not reload.
You have MultiViews enabled on /var/www.
http://httpd.apache.org/docs/current/mod/mod_negotiation.html#multiviews
Try the command:
a2dismod rewrite
Then restart apache. Also make sure there is no .htaccess file in the root directory specifying mod-rewrite settings.