Answer the question
In order to leave comments, you need to log in
How to set up redirect from non-www to www in yii2?
Hello
I'm not very friendly with Apache configs.
In general, a site will be deployed on yii2 with a basic application template. I just can’t make the redirect from bookiebeater.net to www.bookiebeater.net
work.
Here is the config itself from sites-enabled:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.bookiebeater.net
ServerAlias bookiebeater.net
DocumentRoot /var/www/web
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^bookiebeater.net [nocase]
RewriteRule ^(.*) http://www.bookiebeater.net/$1 [last,redirect=301]
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^bookiebeater.net$ [NC]
RewriteRule (.*) http://www.bookiebeater.net/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question