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/
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>
I have a new project created in symfony and I configured httpd-vhosts to bypass all htaccess files that exist in the project's path.
<VirtualHost *:80>
ServerAdmin admin#lab.localhost
DocumentRoot "C:\wamp64\www\lab.localhost"
<Directory "C:\wamp64\www\lab.localhost">
AllowOverride None
AllowOverrideList None
Order Allow,Deny
Allow From All
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ /web [L]
</IfModule>
</Directory>
<Directory "C:\wamp64\www\lab.localhost\web">
AllowOverride None
AllowOverrideList None
Order Allow,Deny
Allow From All
DirectoryIndex app.php
Options FollowSymlinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app_dev.php [QSA,L]
</IfModule>
</Directory>
ServerName lab.localhost
ServerAlias www.lab.localhost.com
ErrorLog "logs/lab.localhost-error.log"
CustomLog "logs/lab.localhost-access.log" common
</VirtualHost>
With this config it gives me Internal Server Error. If I set the AllowOverride and AllowOverrideList to All, it works as expected. The rewrite directves listed here are the same in my htaccess file.
Is there any difference between htaccess and httpd-vhosts?
And if not, why doesn't my config work?
Thank you
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.
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>