Question

My website keeps redirecting from www.mydomain.com to mydomain.com & I have no idea what could be the reason. This is Wordpress Multi User installation, I have nothing in .htaccess which could cause redirect.

I checked the virtual host, it also look right

    ServerAdmin sohail@exleedo.com
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    DocumentRoot /var/www/all.my.sites/public_html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/all.my.sites/public_html/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

Can you help me solve the issue, or tell me how I know from where I can find it is redirecting to mydomain.com

Was it helpful?

Solution

Please login with wordpress admin, and go to setting panel. "yoursite.com/wp-admin/options-general.php"

now change the "Site Address (URL)" (add www with your site url).

OTHER TIPS

Try this one

RewriteEngine On
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Try this. write in .htaccess-

#Redirect non-www urls to www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain\.com [NC]
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top