0

I have this site mamgrow.lt. I want to enter mamgrow.lt in the browser and that www would appear automatically in the link after I enter it. Is it possible?

mamgrow.lt ----> ENTER ----> www.mamgrow.lt

Or should I simply redirect user to www.mamgrow.lt when he enters?

ignas3run
  • 19
  • 1
  • 1
  • 5

3 Answers3

2

You have to create .htaccess and paste this code:

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

See How to create .htaccess file

TRiG
  • 10,148
  • 7
  • 57
  • 107
Rakesh Shetty
  • 4,548
  • 7
  • 40
  • 79
2

If you are using Apache as a webserver you can do this using a .htaccess file:

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

Here is also a generator for creating proper redirects.

TRiG
  • 10,148
  • 7
  • 57
  • 107
Ave Maria
  • 21
  • 2
0

Yes, it is possible using .htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
TRiG
  • 10,148
  • 7
  • 57
  • 107
Justinas
  • 41,402
  • 5
  • 66
  • 96