Deeban Babu
Deeban Babu

Reputation: 729

.htacces redirect not working non-www url to www url

I have tried below code to redirect non www to www url in wordpresss but its not working .

Please check below code is right one?

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.ie[nc]
RewriteRule ^(.*)$ http://www.domain.ie/$1 [r=301,nc]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

Upvotes: 0

Views: 53

Answers (2)

Bud Damyanov
Bud Damyanov

Reputation: 31829

The proper .htaccess rule should be:

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

Keep in mind that Wordpress has own rewrite rules installed in .htaccess file, do not remove them (they are placed between comments lines # BEGIN WordPress and # END WordPress)

Upvotes: 1

Koen Hollander
Koen Hollander

Reputation: 1711

According to the manual at https://www.ostraining.com/blog/wordpress/non-www/

The correct code is

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

Otherwise there may be a other problem that you can reprocedure from the error logs

Upvotes: 0

Related Questions