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.
Asked
Active
Viewed 1,209 times
1 Answers
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
-
This answer is preferable if it is allowed in your environment: http://stackoverflow.com/a/1100363/631764 – Buttle Butkus Jul 02 '15 at 07:34