I have a Laravel project, where i am managing domain and subdomain altogether. That domain and subdomains has different functionalities. When I'm loading my main domain like this https://myclearmargin.com/ without using www it is working perfectly. But when I am adding www https://www.myclearmargin.com/ to the url, it's loading the content of a sub-domain. I am unable to find any solution to this, nor I understand where the problem occurs/where should i dig into. Here is my code on routes/web.php
<?php
$siteUrl = env("APP_URL");
$subdomainRoutes = function () {
// all sub-domain routes
};
$mainRoutes = function () {
// all domain routes
}
Route::group(array('domain' => '{account}.' . $siteUrl), $subdomainRoutes);
Route::group(array('domain' => $siteUrl), $mainRoutes);
My project was deployed on apache (centos 8) server. and here is my apache settings for the project.
domain.conf:
<VirtualHost *:80>
DocumentRoot /var/www/html/MyClearMargin/public
ServerName myclearmargin.com
ServerAlias www.myclearmargin.com
<Directory "/var/www/html/MyClearMargin/public">
Allowoverride All
Options Indexes FollowSymLinks
Require all granted
</Directory>
ErrorLog /var/www/html/log/error.log
RewriteEngine on
RewriteCond %{SERVER_NAME} =myclearmargin.com [OR]
RewriteCond %{SERVER_NAME} =www.myclearmargin.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
subdomain.conf:
VirtualHost *:80>
DocumentRoot /var/www/html/MyClearMargin/public
ServerAlias *.myclearmargin.com
<Directory "/var/www/html/MyClearMargin/public">
Allowoverride All
Options Indexes FollowSymLinks
Require all granted
</Directory>
ErrorLog /var/www/html/log/error.log
</VirtualHost>
Can anyone help me out? I am struggling for this for months. Let me know if you need for informations.
TIA
Related
My application is in Laravel + Vue I'v hosted on Hostinger VPS ubuntu 20.
when I type my site in Google like exptradies.com google showing all the directories as bellow image.
This is my site config
<VirtualHost *:80>
ServerName exptradies.com
ServerAlias www.exptradies.com
ServerAdmin admin#exptradies.com
DocumentRoot /var/www/html/exptradies/public
<Directory /var/www/html/exptradies>
AllowOverride All
Options +FollowSymlinks
Require all granted
ReWriteEngine On
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.exptradies.com [OR]
RewriteCond %{SERVER_NAME} =exptradies.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Does anyone know What I'm missing in the configuration.
for the ssl I use Letsencypt cerbot.
Your web server is configured to show directory indexes. That shows a web page with a list of files for directory requests when the directory does not contain an index document. You can disable this by using
Options -Indexes
That can either go beneath AllowOverride All or in your .htaccess file.
After making the configuration change you will have to wait a couple weeks for Googlebot to recrawl those pages and stop indexing them.
Add public to your path in Directory and this probably will solve your problem
<Directory /var/www/html/exptradies/public>
AllowOverride All
Options +FollowSymlinks
Require all granted
ReWriteEngine On
</Directory>
Don't forget to restart apache service
I try to do my first deploy Laravel 7 + LAMP (Ubuntu).
I succeeded to install Laravel repo I can see my homepage (http://xx.xxx.xx.xxx/).
But when I try to navigate into the website I get this Error:
The requested URL was not found on this server.
I think that i've correctly installed LAMP and Laravel.
The DB is set, I've done the migration.
The problem is probably with the .htaccess, I set my in the repo folder (domain.it/repo):
IfModule mod_rewrite.c>
# That was ONLY to protect you from 500 errors
# if your server did not have mod_rewrite enabled
RewriteEngine On
# RewriteBase /
# NOT needed unless you're using mod_alias to redirect
RewriteCond %{REQUEST_URI} !/public
RewriteRule ^(.*)$ public/$1 [L]
# Direct all requests to /public folder
</IfModule>
And that's my apache2 conf:
<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ServerAdmin social.legambientecapannori#gmail.com
ServerName legambientecapannoriepianalucchese.it
ServerAlias www.legambientecapannoriepianalucchese.it
DocumentRoot /var/www/legambientecapannoriepianalucchese.it/legambiente/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Ah, i've
Thanks in advance
Solved :)
I write the solution for those who will have the same problem
There was an error on the virtual host conf file:
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
I am struggling to host the multiple laravel project in same server in sub-directory.
I want to run laravel project in example.com/CoreApp and example.com/DataSync
Project Directory:
- Root directory (example.com): React Js Project
- CoreApp (example.com/CoreApp) : Laravel Project
- DataSync (example.com/DataSync) : Laravel Project
Here is the current issue I am facing now.
example.com/ => It is working fine.
example.com/CoreApp => It is working fine.
example.com/DataSync => It is serving me 404 page whereas its other routes are working fine. Like example.com/DataSync/telescope is working fine.
Note: Also, I have added RewriteBase /DataSync and RewriteBase /CoreApp in respective project in .htaccess
Here's my config:
Server Config:
- Digital Ocean Server
- Apache web server
- Ubuntu 16
Here is what my virtual host look like.
<VirtualHost *:80>
DocumentRoot /var/www/sites/html
Alias /CoreApp /var/www/sites/html/CoreApp
Alias /DataSync /var/www/sites/html/DataSync
<Directory /var/www/sites/html/CoreApp>
AllowOverride All
DirectoryIndex index.php
</Directory>
<Directory /var/www/sites/html/DataSync>
AllowOverride All
DirectoryIndex index.php
</Directory>
ServerName www.example.com
ServerAlias www.example.com
Redirect permanent / https://example.com/
<Directory "/var/www/sites/html">
Options Includes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerName www.example.com
ServerAlias www.example.com
DocumentRoot /var/www/sites/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateKeyFile /etc/ssl/sites/key/myserver.key
SSLCertificateFile /etc/ssl/sites/certs/example_com.crt
SSLCertificateChainFile /etc/ssl/sites/certs/example_com.ca-bundle
<Directory "/var/www/sites/html">
Options Includes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
Change in you virtual host file for Alias as:
Alias /CoreApp /var/www/sites/html/CoreApp/public
Alias /DataSync /var/www/sites/html/DataSync/public
you have to provide location of public folder
You should provide URL up to your-directory/public. If still issue. then provide URL up to your-directory/public/index.php.
I've a running webapp made in Laravel and served through Apache.
As well known, Laravel's app root is <path_to_project_code>/public.
I want a protected folder under /public, for precision: <path>/public/apidoc.
I am trying this
<VirtualHost <ip_redacted>:80>
ServerName www.mydomain.com
ServerAlias www.mydomain.com
ServerAdmin info#mycompany.it
ServerPath /www.mydomain.com
DocumentRoot /var/www/www.mydomain.com/public/
DirectoryIndex index.html index.php
<Directory /var/www/www.mydomain.com/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
<Directory "/var/www/www.mydomain.com/public/apidoc">
AuthType Basic
AuthName "Authentication Required"
AuthUserFile "/etc/htpasswd/.www.mydomain.com.passwd"
Require valid-user
Order allow,deny
Allow from all
</Directory>
CustomLog ${APACHE_LOG_DIR}/vhosts/www-mydomain-com/access.log vhost_combined
ErrorLog ${APACHE_LOG_DIR}/vhosts/www-mydomain-com/error.log
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
So configured, www.domain.com is served from ....../public, and it's ok.
And www.domain.com/apidoc is served from ....../public/apidoc, and it's ok.
But accessing www.mydomain.com/apidoc DO NOT requires http auth as I want and as I expected.
Added Info
The content of /public/apidoc are static html files generated by APIDocjs.
The simple equivalent of Nginx, working in development, of what I am trying to do is
location /apidoc {
auth_basic "Restricted Area";
auth_basic_user_file /etc/nginx/sites-auth/www.mydomain.com.password;
}
I simply need to port these 4 rows from Nginx to Apache
Resolved.
I removed the entire section
<Directory "/var/www/www.mydomain.com/public/apidoc">
...
</Directory>
Than created /public/apidoc/.htaccess with this content
AuthType Basic
AuthName "APIDoc"
AuthUserFile /etc/htpasswd/.www.mydomain.com.passwd
Require valid-user
Require valid-user
it's my first time to use laravel and config apache and I've a problem with apache document root, it doesn't change.
It always show apache homepage
I'm using a vm with virtualbox, and my conf.d file finish with this lines:
DocumentRoot "/var/www/laravel/public"
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName 192.168.56.3
#ServiceAlias www.test.laravel.com
DocumentRoot /var/www/laravel/public
</VirtualHost>
<Directory "/var/www/laravel/public">
Options FollowSymLinks
ReWriteEngine On
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</Directory>
Do you know what is wrong?
Thank you