1

I've used this bit of code many times for my client's sites, but I'm getting a weird error on one of them. If I use this code, then try to test a non-www page to see if it will redirect, it inserts a subdirectory directly after the .com. For example, example.com/example.html gets redirected to www.example.com/exa/example.html, which is obviously a 404 error. The "exa" subdirectory doesn't even exist.

Any ideas on why this is happening?

# Redirect non-www urls to www
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
BiscuitBaker
  • 1,421
  • 3
  • 23
  • 37

0 Answers0