Roozbeh J
Roozbeh J

Reputation: 77

htaccess on wordpress redirects loop

This question might have been asked before but I believe this case is different, if not please allow me to know and I remove the post.

So I have a WP site V3.9.1 & I realised after upgrading to this version google bots and sitemap couldnt be fetched. So I checked webmaster tools and I can see my domain shows as www.mydomain.com and each time google bots try to fetch it redirects them to domain without www

I added redirect to my .htaccess

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

Now when I add this I still get redirect loop

Domains on my WP settings are as below:

siteurl: http://domain.com home: http://domain.com

I really don't know how to resolve this, any ideas would be perfect.

Thank you all

Upvotes: 1

Views: 86

Answers (1)

anubhava
anubhava

Reputation: 786031

Keep your rule like this as your very first rewrite rule in WP .htaccess:

RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Then keep

site url: http://www.domain.com
home url: http://www.domain.com

Upvotes: 1

Related Questions