0

Google pagespeed service is having trouble today. They are serving my www content.

So I need a quick fix I can put on top of my index php file, to redirect the users to the non-www version, with current page and all.

So if a user lands on my site on www.test.com/some-page/ they will be redirected to test.com/some-page/ instantly

Whats a good way to do this?

Kristian Rafteseth
  • 2,002
  • 5
  • 27
  • 46

1 Answers1

1

You could create a .htaccess file with the following content:

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

The answer in this question explains a solution using PHP instead.

Community
  • 1
  • 1
Kevin
  • 874
  • 3
  • 16
  • 34