The DocumentRoot of example.com is in /var/www/html.
Laravel is installed in /var/www/example/public and I can access it using http://example.com/dashboard but problem arises when I try to access other routes like as http://example.com/dashboard/login and is throwing 404 Not Found error. And saying The requested URL /var/www/example/public/index.php was not found on this server. Can anyone please guide me?
The .htaccess file in the public directory is untouched.
Here is the 000-default.conf:
ServerName example.com
UseCanonicalName Off
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /dashboard /var/www/example/public
<Directory /var/www/example/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
#dynamic subdomain provisioning
<VirtualHost *:80>
DocumentRoot /var/www/example/public
ServerName user.example.com
ServerAlias *.example.com
<Directory /var/www/example/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
I could solve using the following in the 000-default.conf file:
<Directory /var/www/example/public>
DirectoryIndex index.php
AcceptPathInfo on
AllowOverride All
Options None
Order allow,deny
Allow from all
</Directory>
And had to change the laravel .htaccess in the following way:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /dashboard
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ dashboard/$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Related
I have a beta wordpress site (beta.domain.co.uk) I would like to redirect to (domain.co.uk).
I have a .conf file for each site pointing to its folder with the wordpress files.
I have tried just renaming the folders but I get a 404 error.
How can I point the beta site to my main site?
main site conf :
<VirtualHost *:80>
ServerName www.domain.co.uk
DocumentRoot /var/www/domain.co.uk
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/domain.co.uk/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName domain.co.uk
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.co.uk
RewriteRule ^/(.*)$ http://www.domain.co.uk/$1 [L,R=301]
</VirtualHost>
beta site conf:
<VirtualHost *:80>
ServerName beta.domain.co.uk
DocumentRoot /var/www/beta.domain.co.uk
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/beta.domain.co.uk/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
Use the following rewrite rules, make sure you put it inside the beta site conf, inside virtualhost.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^beta\.domain\.co\.uk$
RewriteRule ^(.*)$ http://domain.co.uk/$1 [R=301,L]
I have Internal Server Error (error 500):
[client 5.211.29.235:10910] /home/..../public_html/public/.htaccess: Options not allowed here
mysite.conf:
<VirtualHost *:80>
ServerName mywebsite.com
ServerAlias mywebsite.com *.mywebsite.com
DocumentRoot /home/..../public_html/public/
ErrorLog /home/..../public/error_log
</VirtualHost>
Changing permission to read-write file(755) did not work.
Disable SELinux did not help.
Changing .httaccess also did not help.
changing httpd.conf did not help too.
<Directory />
AllowOverride ALL
</Directory>
or
<Directory "/var/www">
Options Indexes FollowSymLinks MultiViews
AllowOverride Options
Order allow,deny
allow from all
</Directory>
change .htaccess did not work:
Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
problem solved by changing mysite.conf file to this:
<VirtualHost *:80>
ServerName mywebsite.com
ServerAlias mywebsite.com *.mywebsite.com
<Directory />
AllowOverride ALL
</Directory>
DocumentRoot /home/..../public_html/public/
ErrorLog /home/..../public/error_log
</VirtualHost>
Note: See the updates at the end of this post. For the final (working) conf-files see update 4 at the end of this post or the post which I marked as the solution.
I badly configured my apache conf-files and now I'm getting a redirect error (ERR_TOO_MANY_REDIRECTS). I want to redirect everything to HTTPS (non-www). I already tried to add this to the wp-config.php regarding this tips, but that didn't solve the problem:
define('WP_HOME','http://d0main.xyz');
define('WP_SITEURL','http://d0main.xyz');
and I tried to add
define('WP_HOME','https://d0main.xyz');
define('WP_SITEURL','https://d0main.xyz');
Here are my Apache files:
d0main.xyz.conf
<VirtualHost *:80>
ServerName d0main.xyz
ServerAlias www.d0main.xyz
ServerAdmin contact#d0main.xyz
DocumentRoot /var/www/html
Redirect permanent / https://d0main.xyz
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
# changed from None to FileInfo
AllowOverride FileInfo
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
d0main.xyz-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName d0main.xyz
ServerAlias www.d0main.xyz
ServerAdmin d0main#d0main.xyz
DocumentRoot /var/www/html
Redirect permanent / https://d0main.xyz
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
# changed from None to FileInfo
AllowOverride FileInfo
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
SSLCertificateFile /etc/letsencrypt/live/d0main.xyz/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/d0main.xyz/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]
</VirtualHost>
</IfModule>
<IfModule mod_rewrite.c>
Update 1: I solved the redirection error by removing Redirect permanent / https://d0main.xyz in my d0main.xyz-le-ssl.conf, but now there is a / missing at the end of the URL. Graphic URL's for example are now https://d0main.xyzwp-content/image.jpg
Update 2: This is getting more weird. I changed the line Redirect permanent / https://d0main.xyz to Redirect permanent / https://d0main.xyz\/ in my d0main.xyz.conf. Now some images have two slashes (and work) https://d0main.xyz//wp-content/uploads/2016/10/logo-5.png, while other images still have no slash in their URL: https://d0main.xyzwp-content/uploads/2016/10/image2.png
Update 3: I forgot to post my .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Update 4: My final (working) conf-files:
d0main.xyz.conf
<VirtualHost *:80>
ServerName d0main.xyz
ServerAlias www.d0main.xyz
ServerAdmin contact#d0main.xyz
DocumentRoot /var/www/html
Redirect permanent / https://d0main.xyz/
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
# changed from None to FileInfo
AllowOverride FileInfo
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
d0main.xyz-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName delegatex.xyz
ServerAlias www.delegatex.xyz
ServerAdmin delegatexyz#gmail.com
DocumentRoot /var/www/html
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
# changed from None to FileInfo
AllowOverride FileInfo
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
SSLCertificateFile /etc/letsencrypt/live/delegatex.xyz/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/delegatex.xyz/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
<IfModule mod_rewrite.c>
You do not need to escape the forward slash, so instead of Redirect permanent / https://d0main.xyz\/ you should just have Redirect permanent / https://d0main.xyz/. But when redirecting (and ProxyPassing) you should always match trailing slashes.
Instead of the following lines.
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]
You should have a SSL vhost for www.d0main.xyz and jsut do Redirect / https://d0main.xyz/
If you are still getting the double slashes it looks like the reason must be elsewhere. DO you have any htaccess files?
I have been looking at other answers here on stackoverflow and elsewhere, to no avail.
I am running a virtual-host localhost and the homepage of the site is showing up fine, but if I go to any subdirectory/subpage I see this error:
The requested URL /downloads/ was not found on this server
In sum, mydomain.com works, but mydomain.com/downloads/ does not work.
Usually I have fixed this issue with other domains on my localhost by altering .htaccess. Here is my current setup:
Apache2.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
mydomain.com.lc.conf in sites-available
<VirtualHost *:80>
ServerName mydomain.com.lc
ServerAlias www.mydomain.com.lc
ServerAdmin myemail#mydomain.com
DocumentRoot /var/www/html/mydomain.com.lc/com_mydomain/
SetEnv APPLICATION_ENV local
<Directory /var/www/html/mydomain.com.lc/com_mydomain >
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
</Directory>
<Directory /var/www/var/www/html/mydomain.com.lc/com_mydomain/*>
Allow from all
Deny from none
Order deny,allow
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
etc/hosts
127.0.0.1 mydomain.com.lc
.htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I've tried using no .htaccess as well.
have a problem here with Symfony . I want to have virtual host on ubuntu so I can access my Symfony application like this app.local. What I have tried:
<VirtualHost *:80>
ServerName app.local
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
</IfModule>
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
DocumentRoot /var/www/app/web
<Directory /var/www/app/web>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
I added these lines to hosts file
127.0.0.1 app.local
but when I write app.local in my browser, it brings the index of my www directory(default apache page). What am I doing wrong?
Try this :
/etc/apache2/sites-available/mysite.conf
<VirtualHost *:80>
ServerName app.local
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
</IfModule>
DocumentRoot /var/www/app/web
<Directory /var/www/app/web>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Then apply configuration changes :
$>sudo a2ensite mysite // If not already enabled
$>sudo service apache2 restart
If the problem is not solved, check the error logs in /var/log/apache2/