0

I have a domain name www.xyz.com and I want to make sure if someone types xyz.com into address bar they will be redirected to www.xyz.com and also if someone types xyz.com/somepage.php it should redirect to www.xyz.com/somepage.php How can I do this using .htaccess files? I have tried several examples but no luck.

Ersel Aker
  • 835
  • 9
  • 26

1 Answers1

1

Put these lines in your .htacess file:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On

# if host is xyz.com
RewriteCond %{HTTP_HOST} ^(xyz\.com)$ [NC]
# redirect to www.xyz.com/uri
RewriteRule ^ http://www.%1%{REQUEST_URI} [R=301,L]
anubhava
  • 761,203
  • 64
  • 569
  • 643