laravel 5.3: setup virtual host. Getting Apache 404 error - apache

I want to setup a virtual host in my localhost, so I can access my Laravel app like this: demo.example.com. I have added a custom conf file: etc/apache2/sites-available/example.com.conf with the following contents:
<VirtualHost *:80>
ServerAdmin username#gmail.com
ServerName example.com
ServerAlias www.example.com
ServerAlias demo.example.com
ServerAlias www.demo.example.com
DocumentRoot /var/www/example/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/example/public>
AllowOverride All
</Directory>
</VirtualHost>
Contents from /etc/hosts file:
127.0.0.1 localhost
127.0.1.1 username-pc
127.0.0.1 example.com
127.0.0.1 www.example.com
127.0.0.1 http://exaple.com
127.0.0.1 demo.example.com
With the above settings if I access the url demo.example.com it works. But if I try to access other routes like demo.example.com/login I get apache 404 error: The requested URL /login was not found on this server. How do I fix this?
Note that this is not laravel's NotFoundHttpException.

place this under your directory tag
<Directory /var/www/example/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

Related

(Apache) Forbidden 403 when accessing subdomain

I want to set up the subdomain "shop" on my Apache 2.2 server on Windows/XAMPP and it redirects to "index.html" if I enter "shop.localhost" as the URL but once I try to connect via my domain "sv443.net" it redirects to my document root ("/index.html" instead of "/shop/index.html"). Connecting to "sv443.net/shop/" works fine though and even redirects to "index.html".
I'm using Cloudflare to handle the DNS stuff and added these records (I cut off the IP address part):
This is my httpd-vhosts.conf:
NameVirtualHost localhost:80
<VirtualHost localhost:80>
ServerName localhost
ServerAdmin sven.fehler#web.de
DocumentRoot "c:/users/sv443/desktop/mamp htdocs"
<Directory "c:/users/sv443/desktop/mamp htdocs">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost shop.localhost:80>
ServerName shop.localhost
ServerAdmin sven.fehler#web.de
DocumentRoot "c:/users/sv443/desktop/mamp htdocs/shop"
<Directory "c:/users/sv443/desktop/mamp htdocs/shop">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
And this is my hosts.dat:
(only comments)
2.205.169.73 sv443.net
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost shop.localhost
Also I added this .htaccess file to the shop directory to redirect to the index.html if a 403 or 404 is encountered - removing this file doesn't fix my problem:
ErrorDocument 403 /shop/index.html
ErrorDocument 404 /shop/index.html
If someone tries to connect I get this error message in the Apache error.log:
AH01630: client denied by server configuration: C:/Users/Sv443/Desktop/MAMP htdocs/shop/.html
Thanks for any help!
If you can get content by explicitly specifying "/index.html" but not with "/", you should add DirectoryIndex index.html in your configuration, after loading mod_dir. This will define the default file to look for when it is not specified.
For your VirtualHost:
<VirtualHost *:80>
ServerName localhost
ServerAlias www.example.com
ServerAlias example.com
LogLevel debug
CustomLog "logs/example_access_log" combined
ErrorLog "logs/example_error_log"
[... REST OF CONFIGURATION ...]
</VirtualHost>
<VirtualHost *:80>
ServerName shop.localhost
ServerAlias shop.example.com
LogLevel debug
CustomLog "logs/shop_access_log" combined
ErrorLog "logs/shop_error_log"
[... REST OF CONFIGURATION ...]
</VirtualHost>
Apache decides which VirtualHost to use for the request based on the domain in the request. If it does not find a match, it uses the first one in the file (here localhost). Therefore you are not pointing to your "shop" sub-domain, unless you specify it in the VirtualHost for it, via ServerAlias ....

Apache2 does not serve ServerAlias without www

This is my sites-available/FlaskApp.conf file
<VirtualHost *:80>
ServerName www.mywebsite.design
ServerAlias mywebsite.design
ServerAdmin myemail#gmail.com
WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
<Directory /var/www/FlaskApp/FlaskApp/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/FlaskApp/FlaskApp/static
<Directory /var/www/FlaskApp/FlaskApp/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
www.mywebsite.design works when i open on the browser correctly. However when i go to mywebsite.design the Ubuntu Default "It Works" page shows up.
I followed this tutorial Hosting a FlaskApp
When i tried IPAddress as the Servername like this -
ServerName 139.55.55.55
for some reason the opening the IP address on the browser opens correctly but both www.mywebsite.design or mywebsite.design don't shows the same Ubuntu Default Page
I had mywebsite.design on /etc/hosts like this -
127.0.1.1 mywebsite.design mywebsite
. probably because i named the project that way at some point!
Removed it and just put my name there and it worked!

wamp server put online for anyone to access

Hi ive been attempting to set up a wamp server so people can access it for testing
everything works correctly on my pc and i believe i have everything set up correctly but noone can connect to the site as it cant be reached
i have opened port 80 on my router and my firewall
my hosts file is as follows
127.0.0.1 localhost
::1 localhost
127.0.0.1 bandicam.com
127.0.0.1 ssl.bandisoft.com
127.0.0.1 btcGame.local
::1 btcGame.local
my httpd-vhosts.conf is as follows
#
# Virtual Hosts
#
<VirtualHost *:80>
DocumentRoot "g:/wamp/www"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
<Directory "G:/wamp/www">
AllowOverride All
Options Indexes FollowSymLinks
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName btcGame.local
ServerAlias www.btcGame.local
DocumentRoot "c:/wamp64/www/btcgame"
ErrorLog "logs/btcGame-error.log"
CustomLog "logs/btcGame-access.log" common
<Directory "/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
is there any other things i need to change in order to get my website online?
Other people trying to access your computer should know where to look.
Your server should then be referenced in the hosts file of their machine, except that IP should be resolvable such as
your.local.ip btcGame.local

Apache 2.4.9 Virtual Host on WAMP port 100 On Windows 10 503 error

I keep getting a 503 error when I try to set up a virtual host. I can set up an aliased folder just fine, but no luck on the virtual host setup.
My hosts file looks like this:
127.0.0.1 localhost
::1 localhost
127.0.0.1 appmarket.local
::1 appmarket.local
My vs-hosts file looks like this:
<VirtualHost *:100>
DocumentRoot "C:/nanomarketvhost/local"
ServerName appmarket.local
ServerAlias appmarket.local
ErrorLog "logs/appmarket-error.log"
CustomLog "logs/appmarket-access.log" common
<Directory "C:/nanomarketvhost/local">
AllowOverride All
Options Indexes FollowSymLinks
Require local
</Directory>
</VirtualHost>
<VirtualHost *:100>
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
<Directory "C:/wamp/www">
AllowOverride All
Options Indexes FollowSymLinks
Require local
</Directory>
</VirtualHost>
I have commented out the lines in the httpd.conf to load virtual hosts.

Trying to get subdomains working locally with codeigniter and mamp

I'm trying to follow this tut http://net.tutsplus.com/tutorials/php/basecamp-style-subdomains-with-codeigniter/ to get subdomains working locally.
I've added this to the /etc/hosts file
127.0.0.1 snapgiftapp.com
127.0.0.1 test1.snapgiftapp.com
127.0.0.1 test2.snapgiftapp.com
and i've added this to the end of the /Applications/MAMP/conf/apache/httpd.config file
<VirtualHost *:80>
DocumentRoot "/Users/tomcaflisch/Sites/snapGiftAppFront"
ServerName snapgiftapp.com
ServerAlias snapgiftapp.com
<Directory "/Users/tomcaflisch/Sites/snapGiftAppFront">
Options -Indexes
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/tomcaflisch/Sites/snapGiftApp"
ServerName snapgiftapp.com
ServerAlias *.snapgiftapp.com
<Directory "/Users/tomcaflisch/Sites/snapGiftApp">
Options -Indexes
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
When I point my browser to snapgiftapp.com or test1.snapgiftapp.com, I get the same site located in the snapGiftAppFront folder
I had to go into the mamp configurations and change the port to 80 instead of 8888.