I have a codeigniter site running on a Apache web server
I installed an SSL from letsencrypt
My site works fine if I access it through http://example.com
but,
If I access it through https://example.com the site shows but the database is broken
This is my htaccess file
Include /etc/phpmyadmin/apache.conf
<VirtualHost *:80>
ServerName example.org
ServerAlias www.example.org
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
RewriteEngine on
RewriteRule "^/resources/(.+)" "https://example.org/_resources/$1"$
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ProxyPass /api https://localhost:8010/api
ProxyPassReverse /api https://localhost:8010/api
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName example.org
ServerAlias www.example.org
DocumentRoot /var/www/html/
Include /etc/letsencrypt/options-ssl-apache.conf
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/example.org-0001/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.org-0001/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.org-0001/chain.pem
</VirtualHost>
Fixed this issue by adding inside of the <VirtualHost *:443> tag
<Directory /var/www/html>
AllowOverride All
</Directory>
Related
I just installed XAMPP on my Mac. After configured everything and tried to run myProject on localhost 8080 the following error showed up on the web.
localhost:8080/myProject
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.46 (Unix) OpenSSL/1.1.1g PHP/7.4.9 mod_perl/2.0.11 Perl/v5.32.0
Here's the configurations for XAMPP
Here's the files under htdocs
Document root:
DocumentRoot "/opt/lampp/htdocs"
<Directory "/opt/lampp/htdocs">
Include etc/extra/httpd-xampp.conf
Include "/opt/lampp/apache2/conf/httpd.conf"
httpd.xampp.conf
<Directory "/opt/lampp/phpmyadmin">
AllowOverride AuthConfig Limit
Require all granted
ErrorDocument 403 >/error/XAMPP_FORBIDDEN.html.var
</Directory>
apache2/conf/httpd.conf
Alias /bitnami/ "/opt/lampp/apache2/htdocs/"
Alias /bitnami "/opt/lampp/apache2/htdocs"
<Directory "/opt/lampp/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
etc/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "/opt/lampp/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" >common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "/opt/lampp/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" >common
</VirtualHost>
<VirtualHost laravel.local:80>
DocumentRoot "
/Users/phamminh/.bitnami/stackman/machines/xampp/volumes/root/htdocs/myProject/public"
ServerAdmin laravel.local
<Directory "
/Users/phamminh/.bitnami/stackman/machines/xampp/volumes/root/htdocs/myProject">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Hi I have browsed all the resources, but still seems can't find the solution.
I have XAMPP Control Panel v 3.2.4 (compiled Jun 5th 2019) installed on my computer, it is installed in d:\xampp. I want to create a Virtual host, so that I can correctly use various global PATH variables.
I followed instructions closely.
This is from my D:\xampp\apache\conf\extra\httpd-vhosts.conf:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "D:\xampp\htdocs"
<Directory "D:\xampp\htdocs">
DirectoryIndex index.php
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName ikeen.localhost
DocumentRoot "D:\xampp\htdocs\ikeen"
SetEnv APPLICATION_ENV "development"
<Directory "D:\xampp\htdocs\ikeen">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I have added following lines to the end of httpd.conf:
<Directory />
AllowOverride none
Require all granted
</Directory>
I have the following line in my hosts file in windows:
127.0.0.1 ikeen.localhost
This is the structure of my site directory
In order to avoid cache I open URL in the incognito mode and from different browsers. I always get redirect to dashboard - https://ikeen.localhost/dashboard/, it opens the standard "Welcome to XAMPP for Windows 7.4.3"
I have heard that it has something to do with https, as I'm always transferred to https URL even if I try to use http. I've looked at httpd-ssl.conf, but I don't know what to do there. Any ideas?
Finally! For everyone who is looking for the solution do the following:
My desired site is located at D:\xampp\htdocs\ikeen.
1) Add this to your httpd-vhosts.conf:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "D:\xampp\htdocs"
<Directory "D:\xampp\htdocs">
DirectoryIndex index.php
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName ikeen.localhost
DocumentRoot "D:\xampp\htdocs\ikeen"
SetEnv APPLICATION_ENV "development"
<Directory "D:\xampp\htdocs\ikeen">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
2) Add this to the end of httpd.conf:
<Directory />
AllowOverride none
Require all granted
</Directory>
3) Add this line to your hosts file in Windows directory
127.0.0.1 ikeen.localhost
4) Finally, this is the step that is missing from all the solutions. Add this to your httpd-ssl.conf, after the same section for your localhost (usually www.example.com), change example.com to your local settings for localhost, so that the whole section looks smth like this
<VirtualHost _default_:443>
# General setup for the virtual host
DocumentRoot "D:/xampp/htdocs"
#ServerName www.example.com:443
ServerName localhost
ServerAdmin admin#example.com
ErrorLog "D:/xampp/apache/logs/error.log"
TransferLog "D:/xampp/apache/logs/access.log"
# General setup for the ikeen host
DocumentRoot "D:/xampp/htdocs/ikeen"
#ServerName www.example.com:443
ServerName ikeen.localhost
ServerAdmin admin#example.com
ErrorLog "D:/xampp/apache/logs/error.log"
TransferLog "D:/xampp/apache/logs/access.log"
I had the same issue. Problem was solved by removing the standard virtual host entry and i wasn't redirected to the root directory.
Just remove these lines of code:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "D:\xampp\htdocs"
<Directory "D:\xampp\htdocs">
DirectoryIndex index.php
</Directory>
</VirtualHost>
If the case does not work, maybe change httpd-ssl.conf
My 3 sites worked, localhost, test1.com, test2.com
#
<VirtualHost _default_:443>
DocumentRoot "c:/xampp/htdocs"
ServerName localhost
ServerAdmin admin#example.com
ErrorLog "c:/xampp/apache/logs/error.log"
TransferLog "c:/xampp/apache/logs/access.log"
...
</VirtualHost>
#test1
<VirtualHost _default_:443>
DocumentRoot "c:/xampp/htdocs/test1"
ServerName test1.com
ServerAdmin admin#example.com
ErrorLog "c:/xampp/apache/logs/error.log"
TransferLog "c:/xampp/apache/logs/access.log"
...
</VirtualHost>
#test2
<VirtualHost _default_:443>
DocumentRoot "c:/xampp/htdocs/test2"
ServerName test1.com
ServerAdmin admin#example.com
ErrorLog "c:/xampp/apache/logs/error.log"
TransferLog "c:/xampp/apache/logs/access.log"
...
</VirtualHost>
I have unizped codeigniter on /var/www/control_cuotas indx.php is placed on that folder and I settrd up a new virtualhost on apache on the 000-default.conf file whith this code
<VirtualHost *:81>
<Directory /var/www/control_cuotas>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/control_cuotas
ServerAlias www.control_cuotas.test
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
But I cannot acces to localhost:81 its Unable to connect and the serve rwas restarted before I tried to access
For example:
<VirtualHost *:80>
ServerName your_project
DocumentRoot "C:/wamp64/www/your_project"
<Directory "C:/wamp64/www/your_project/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
Let's try one more time.
Make sure all your VirtualHosts define a ServerName. Failure to do so will mean trouble as you add more hosts.
<VirtualHost *:80>
DocumentRoot /var/www/control_cuotas
ServerName control_cuotas.test
ServerAlias www.control_cuotas.test
ServerAdmin webmaster#localhost
<Directory /var/www/control_cuotas>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Don't forget to enable the above config in Apache adding it to the sites-enabled list. Then restart Apache.
The file /etc/hosts should look like this at a minimum
127.0.0.1 localhost
127.0.0.1 control_cuotas.test
127.0.0.1 www.control_cuotas.test
Other VHosts should also be represented in this file.
You can also add entries for ipV6 if you want, but it is not a requirement in most cases. (The main case is that you have disabled communication using ipV4.)
I have the same configuration and set up only the versions of Apache2 are slightly different. I have set up /api to load the /public.
So, locally (apache 2.4.18)
mysite.local correctly loads /var/www/mysite/application
mysite.local/api correctly loads /var/www/mysite/public
mysite.local/api/subdirectory correctly loads /var/www/mysite/public
I want to replicate this on a hosted dev server (Apache 2.4.7) however I am getting the following:
mysite.devserver.com correctly loads /var/www/html/mysite/application
mysite.devserver.com/api correctly loads /var/www/html/mysite/public
mysite.devserver.com/api/subdirectory incorrectly loads /var/www/html/mysite/application
Local mysite.conf file (working)
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName mysite.local
ServerAlias www.mysite.local
Alias /api /var/www/mysite/public
<Directory /var/www/mysite/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
RewriteEngine On
</Directory>
DocumentRoot /var/www/mysite/application
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Dev server conf file (not working)
<VirtualHost *:80>
ServerName mysite.devserver.com
ServerAdmin webmaster#localhost
Alias /api /var/www/html/mysite/public
<Directory /var/www/html/mysite>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
RewriteEngine On
</Directory>
DocumentRoot /var/www/html/mysite/application
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I have also tried to add the Alias into mods-enabled but its not making a difference. The code is the exact same, same .htaccess files in both instances.
I am trying to use a virtualhost with an alias to deploy a Laravel application.
Using apache2 in ubuntu 16.04.
My 000.conf file is:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options -Indexes
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>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/public
Alias /expediente "/var/www/public/"
<Directory /var/www/public/>
Options -Indexes
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>
</VirtualHost>
The first one is working ok but the second one does not.
What am I doing wrong?
==============
EDIT
Ok so i made two conf files in sites available and symlinked them to sites-enabled.
advanced.conf
<VirtualHost *:80>
ServerAdmin admin#localhost
ServerName ip-address:80/advanced
ServerAlias /advanced
DocumentRoot /var/www/html/advanced
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
expediente.conf
<VirtualHost *:80>
ServerAdmin admin#localhost
ServerName ip-address:80/expediente
ServerAlias /expediente
DocumentRoot /var/www/html/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Reloaded and restarted apache2.
If i try to navigate to ip-address/ i get the first page, the advanced,
If i try to navigate to ip-address/advanced 404 not found
If i try to navigate to ip-address/expediente 404 not found
What am i doing wrong?
its good practice create different host file for your alias. you can use this command to copy default config for your second alias with this command
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf
and open it in whichever editor you like and put this content
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
save and close the file then run this command
sudo a2ensite example.com.conf
and restart your apache
You gonna need ServerName in your virtual hosts configurations, its probably always defaulting to the first one without that. For example
ServerName mydomain.net
Si tus proyecto esta de la forma http://localhost/AppName, entonces debes colocar en el httpd.conf
<VirtualHost site1.local:80>
ServerAdmin webmaster#example.com
DocumentRoot /path/to/htdocs/site1
ServerName www.site1.local
ServerAlias site1.com
</VirtualHost>
y el segundo.
<VirtualHost site2.local:80>
ServerAdmin webmaster#example.com
DocumentRoot /path/to/htdocs/site2
ServerName www.site2.local
ServerAlias site2.com
</VirtualHost>