I am trying to set Larval up on a virtual host as a sub domain. when I go to the site it shows the index directory. in my /etc/apache2/sites-available/.conf file, my document root is pointing to public. when I click on the public folder in the browser the server gives a 500 error.
<VirtualHost *:80>
ServerName subdomain.mainwebsite.space
ServerAlias www.subdomain.mainwebsite.space
ServerAdmin support#mainwebsite.com
DocumentRoot /var/www/subdomain/public
<Directory /var/www/subdomain/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
#Redirect "https://subdomain.mainwebsite.space"
#SSLEngine on
#SSLCertificateFile /etc/encryption/certificate.crt
#SSLCertificateKeyFile /etc/encryption/server.key
#SSLCertificateChainFile /etc/encryption/intermediate.crt
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
#RewriteCond %{SERVER_NAME} =subdomain.mainwebsite.space [OR]
#RewriteCond %{SERVER_NAME} =www.subdomain.mainwebsite.space
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
<VirtualHost/>
I have also changed permissions on public folder to 775. I am not sure what else i should be doing. I have a static public ip and a static internal ip and restarted apache service. Any help will surely be appreciate
Related
I'm building webapp on Ubuntu + Apache2 with wildcard SSL certificates
My goal is to set up functioning project on 1st level domain project.app as well as several subdomains marketplace.project.app & partners.project.app
All of the project files are under the same directory:
www/project/
subdomains accessible via laravel router:
Route::domain('marketplace.project.app')->group(function () {
Route::view('','pages.marketplace');
});
serverside DNS records:
A | project.app | 127.0.0.1
A | *.project.app | 127.0.0.1
/sites-available/default-ssl.conf:
ServerName project.app
ServerAlias *.project.app
DocumentRoot /var/www/project/public
<Directory /var/www/project>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
.htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^127\.0\.0\.1
RewriteRule (.*) https://project.app/$1 [R=301,L]
All of the wildacrd subdomains e.g. bbb.project.app work flawlessly, but upon accessing app in browser via 1st level project.app apache does not render index.php file.
Is the setup I'm thriving for feasible in apache or should I switch to Ngnix?
Just to alert, You do not really need to use htaccess rules once you use apache2, ybecause "blahblahblah.conf" can handle htaccess rules.
To handle multiple domains and including htaccess rules with it, you can do the following (working example):
<VirtualHost *:80>
ServerName example.com
ServerAlias foo.example.com bar.example.com others.example.com
DocumentRoot "/var/www/laravel_folder/public"
<Directory /var/www/laravel_folder/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [or]
RewriteCond %{SERVER_NAME} =www.example.com [or]
RewriteCond %{SERVER_NAME} =foo.example.com [or]
RewriteCond %{SERVER_NAME} =www.foo.example.com [or]
RewriteCond %{SERVER_NAME} =bar.example.com [or]
RewriteCond %{SERVER_NAME} =www.bar.example.com [or]
RewriteCond %{SERVER_NAME} =others.example.com [or]
RewriteCond %{SERVER_NAME} =www.others.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
I have an Apache2 virtual host where I'll be hosting several Laravel applications.
The VH document root is /home/user/applications/portal.
The laravel applications are in:
/home/user/applications/portal/larapps/larapp1
/home/user/applications/portal/larapps/larapp2
...
I want the URLs to be like:
http://portal.com/larapp1/...
http://portal.com/larapp2/...
So this is my config:
<VirtualHost *:80>
ServerName portal.com
DocumentRoot /home/user/applications/portal
Alias /larapp1 /home/user/applications/portal/larapps/larapp1/public
<Directory /home/user/applications/portal/larapps/larapp1/public>
RewriteEngine On
RewriteBase /larapps/larapp1/public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [L]
</Directory>
</VirtualHost>
If the request is http://portal.com/larapp1 then the route that matches is as I expect: Route::get('/',...).
But, inexpectedly, if I add any URI in the request, it doesn't do what I want. For example, if the request is http://portal.com/larapp1/foo, it doesn't match Route::get('/foo',...) but Route::get('/larapp1/foo',...).
What should I do so that routes are matched without the prefix /larapp1?
I found it! My bad, I did a mistake in the configuration: I used a filesystem path in RewriteBase, when I should have indicated a base URI. This is the right config:
<VirtualHost *:80>
ServerName portal.com
DocumentRoot /home/user/applications/portal
Alias /larapp1 /home/user/applications/portal/larapps/larapp1/public
<Directory /home/user/applications/portal/larapps/larapp1/public>
RewriteEngine On
RewriteBase /larapp1/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [L]
</Directory>
</VirtualHost>
I have windows server and have domain of godaddy. I took SSL from godaddy and apply on my server. My domain gets secure by SSL but problem come when, i redirect from https://www.example.com and logged in it shows dashboard but when i change url to https://example.com it redirect me to login page.
Here is my VHOST file
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "C:/mcpluat/xampp/htdocs/project/public"
ServerName www.example.com
ServerAlias example.com
RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/ [R,L]
<Directory "C:/mcpluat/xampp/htdocs/project/public">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
.HTACCESS file
Options -MultiViews -Indexes
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Everything is working perfectly but why it is treating www.example.com and example.com a different domain
Thanks in advance
I've confused using ubuntu for setting up virtual host for CI in apache2.
I have website for running in locally using virtual host, but when I open my navigation link like.
mysite.com/about_us
It can't be open, and said : 404 Not Found
This is my virtual host code
<VirtualHost *:80>
ServerAdmin webmaster#blade.co.loc
ServerName blade.co.loc
ServerAlias www.blade.co.loc
DocumentRoot /var/www/html/new/
<Directory /var/www/html/new/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
And this is my .htaccess code
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine On
RewriteBase /new/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
Follow this steps. It will lead you in correct path. It has describe every details. And also check you have correctly given the link in routes.php. This is for creating virtual host in ubuntu
https://support.rackspace.com/how-to/set-up-apache-virtual-hosts-on-ubuntu/
I created the virtual in wamp server. Everything is working but i can't able to remove the index.php. I don't know how to write the .htaccess.
Here is the details
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot E:/Projects/OnGoing/bonanza/dev.bonanza.com
ServerName dev.bonanza.com
<Directory "E:/Projects/OnGoing/bonanza/dev.bonanza.com">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
and my htaccess
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Allow these directories and files to be displayed directly:
# - index.php (DO NOT FORGET THIS!)
# - robots.txt
# - favicon.ico
# - Any file inside of the media/ directory
RewriteRule ^(index\.php|robots\.txt|favicon\.ico|media|uploads|js|css|images|plugins|source|files|fonts|lib|plugins) - [PT,L]
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php?/$0 [PT,L,QSA]
Did you setup your host file correctly to read the path of your site? For me I used this all the time works fine in development server.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]