Hello i have a site on my own computer hosting. I setup wordpress and apache on it. Got a domain name and registered it on cloudflare. They also offer a free certificate which i got and put into folder .crt and .key files. Here is my configuration for ssl and non-ssl for apache
HTTPS
<VirtualHost *:443>
ServerName hascelin.fun
ServerAdmin hascelin#gmail.com
DocumentRoot /var/www/html/hascelin.fun/
ServerAlias www.hascelin.fun
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/hascelin.fun/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
#RewriteEngine on
#RewriteCond %{SERVER_NAME} =www.hascelin.fun [OR]
#RewriteCond %{SERVER_NAME} =hascelin.fun
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
SSLEngine on
SSLCertificateFile /home/orest/cert/hascelin.crt
SSLCertificateKeyFile /home/orest/cert/hascelin.key
</VirtualHost>
HTTP
<VirtualHost *:80>
ServerName hascelin.fun
ServerAdmin hascelin#gmail.com
DocumentRoot /var/www/html/hascelin.fun/
ServerAlias www.hascelin.fun
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/hascelin.fun/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
#RewriteEngine on
#RewriteCond %{SERVER_NAME} =www.hascelin.fun [OR]
#RewriteCond %{SERVER_NAME} =hascelin.fun
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
#SSLEngine on
#SSLCertificateFile /home/orest/cert/hascelin.crt
#SSLCertificateKeyFile /home/orest/cert/hascelin.key
Media files are loading from http
Related
when I do not include the http:// or https:// prefix, my site does not load.
For example, these don't load:
example.com , www.example.com
But this does:
https://example.com, http://example.com, http://www.example.com, https://www.example.com
I am using Apache as my webserver, and here is my sites-available conf:
<VirtualHost *:80>
ServerAdmin
DocumentRoot /var/www/html
ServerName example.com
ServerAlias www.example.com
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
</IfModule>
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
I do have an SSL Cert, generated by certbot.
Any ideas on why this is happening?
Thanks in advance
you can try this
<VirtualHost *:80>
ServerAdmin
DocumentRoot /var/www/html
ServerName example.com
ServerAlias www.example.com
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
</IfModule>
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://{SERVER_NAME}%{REQUEST_URI} [L,NE,R=301]
I currently issued a SSL Certificate to my Ubuntu 17.01 server with Apache2. I tried to redirect HTTP to HTTPS but my Laravel Project now is not exist. but the Ubuntu Default Page works.
My SSL conf
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
ServerAdmin webmaster#localhost
ServerName pdrrmo-bulacan.me
ServerAlias www.pdrrmo-bulacan.me
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/pdrrmo-bulacan.me.crt
SSLCertificateKeyFile /etc/apache2/ssl/pdrrmo-bulacan.me.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
my laravel conf
<VirtualHost *:80>
ServerAdmin einnar82#gmail.com
DocumentRoot /var/www/html/pdrrmo-prod/public
ServerName pdrrmo-bulacan.me
ServerAlias www.pdrrmo-bulacan.me
Redirect / https://pdrrmo-bulacan.me
<Directory /var/www/html/pdrrmo-prod/>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I try to force all urls to https except one url. so far no success. Anyone knows what is wrong with my htaccess or codeignter?
Url test 1:
http://hub-dev-1.andatech.com.au/utility/mandrills/email_bounced_back
Should stays as
http://hub-dev-1.andatech.com.au/utility/mandrills/email_bounced_back
Url test 2:
http://hub-dev-1.andatech.com.au/controller/method
I use this tool to test htaccess: http://htaccess.mwl.be/
Here is my htaccess
RewriteOptions inherit
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/utility/mandrills/email_bounced_back
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} !^/(assets|test)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php/$1 [PT,L]
Header set Access-Control-Allow-Origin "*"
Test on http://htaccess.mwl.be, working.
Test on browser,
http://hub-dev-1.andatech.com.au/utility/mandrills/email_bounced_back redirects to
https://hub-dev-1.andatech.com.au/utility/mandrills/email_bounced_back
apache conf:
<VirtualHost *:80>
ServerAdmin test#test.com
ServerName hub-dev-1.andatech.com.au
ServerAlias www.hub-dev-1.andatech.com.au
DocumentRoot /home/thehub/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /home/thehub/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
# Hak apache 2.2
# Order deny,allow
Allow from all
# Hak apache 2.4
Require all granted
</Directory>
</VirtualHost>
ssl apache conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin test#test.com
ServerName hub-dev-1.andatech.com.au
ServerAlias www.hub-dev-1.andatech.com.au
DocumentRoot /home/thehub/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /home/thehub/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
# Hak apache 2.2
# Order deny,allow
Allow from all
# Hak apache 2.4
Require all granted
</Directory>
SSLCertificateFile /etc/letsencrypt/live/hub-dev-1.andatech.com.au/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/hub-dev-1.andatech.com.au/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
I am having an issue with getting Laravel to work properly with Apache2. This is my config file, but whenever it go to my domain I see directory list, and I need to enter to portfolio/public to see the app. That's also what the url become (my-website.com/portfolio/public/).
Is there any way I can fix this?
I've been trying to deploy this app for 3 days and still had no success...
Great Thanks!
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName my-domain.com
ServerAlias www.my-domain.com
DocumentRoot /var/www/html/portfolio/public
<Directory /var/www/html/portfolio/public>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<Directory /var/www/html/portfolio/public>
Options 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>
This might help you
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /public/index.php/$1 [L]
Source
This is my /etc/apache2/sites-availables/mysite.com file configuration
ServerAdmin LOLILOL#LOL.com
ServerName www.example.com
Redirect permanent / http://www.example.com/
ServerAlias example.com
DocumentRoot /home/example/www
SuexecUserGroup example example
<Directory />
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Allow from all
</Directory>
<Directory /home/example/www>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Please can Someone tell my where to find the issue to redirect non www to www ?
PS : I can't acces to my site from http://example.com (Only from http://www.example.com/)
HELP ME PLEASE !!!!
I do it in the .htaccess.
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]