apache 2 WWW redirection issue

39 Views Asked by At

This is my /etc/apache2/sites-availables/mysite.com file configuration

ServerAdmin [email protected]

ServerName www.example.com
Redirect permanent / http://www.example.com/

ServerAlias example.com

DocumentRoot /home/example/www
SuexecUserGroup example example
<Directory />

Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Allow from all
</Directory>
<Directory /home/example/www>
    Options FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined

Please can Someone tell my where to find the issue to redirect non www to www ?

PS : I can't acces to my site from http://example.com (Only from http://www.example.com/)

HELP ME PLEASE !!!!

1

There are 1 best solutions below

0
On

I do it in the .htaccess.

RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]