Free Web Hosting Forum
(#1)
Old
ahmadlou ahmadlou is offline
Junior Member
ahmadlou is on a distinguished road
 
Posts: 5
Join Date: Mar 2015
Default I want to use www. - 03-08-2015, 11:51 AM

Hello, I want to force my visitors to visit my website with www. I searched for this and found this;
http://www.htaccessbasics.com/force-www-nonwww-domain/
As you can see is need to edit htaccess file but I can't find in in my host that where is it?
Also I want to know if you know better option for do this.
Thanks in advance
Reply With Quote

(#2)
Old
Bad Karma[CORE]'s Avatar
Bad Karma[CORE] Bad Karma[CORE] is offline
333 - only half evil
Bad Karma[CORE] is on a distinguished road
 
Posts: 7,386
Join Date: May 2008
Default 03-08-2015, 12:27 PM

Here is what i use to force a www redirect
Code:
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
There should be a default .htaccess file in your public_html directory. If there isn't then you can upload a simple .txt file like htaccess.txt and then, when uploaded, rename it to .htaccess


Get in touch with me

Excellent Free Hosting
Reply With Quote
(#3)
Old
ahmadlou ahmadlou is offline
Junior Member
ahmadlou is on a distinguished road
 
Posts: 5
Join Date: Mar 2015
Default 03-08-2015, 12:34 PM

Thanks for your reply, I made the .htaccess as you said and about your code where I must put my website address with www. to make it work?
Reply With Quote
(#4)
Old
Bad Karma[CORE]'s Avatar
Bad Karma[CORE] Bad Karma[CORE] is offline
333 - only half evil
Bad Karma[CORE] is on a distinguished road
 
Posts: 7,386
Join Date: May 2008
Default 03-08-2015, 12:34 PM

you just need to put the code in the .htaccess file.


Get in touch with me

Excellent Free Hosting
Reply With Quote
(#5)
Old
ahmadlou ahmadlou is offline
Junior Member
ahmadlou is on a distinguished road
 
Posts: 5
Join Date: Mar 2015
Default 03-08-2015, 12:36 PM

I put it but it is not work?!

I used this as mentioned website said and it works;
# Redirect non-www urls to www
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yoursite\.com
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]
anyway thanks a lot

Last edited by d3iti; 03-08-2015 at 01:51 PM.
Reply With Quote
(#6)
Old
fuzzler fuzzler is offline
Member
fuzzler is on a distinguished road
 
Posts: 65
Join Date: Feb 2015
Default 03-08-2015, 02:41 PM

Quote:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
How about that?
Reply With Quote
(#7)
Old
ahmadlou ahmadlou is offline
Junior Member
ahmadlou is on a distinguished road
 
Posts: 5
Join Date: Mar 2015
Default 03-08-2015, 03:37 PM

Quote:
Originally Posted by fuzzler View Post
How about that?
As I said it didn't work for me.
Reply With Quote
(#8)
Old
DanielNichesite3 DanielNichesite3 is offline
Junior Member
DanielNichesite3 is on a distinguished road
 
Posts: 21
Join Date: Feb 2015
Default 03-09-2015, 05:04 PM

If you're using wordpress now. It's quite simple. Go to settings > general > change the link to http://www.yoursite.com
Reply With Quote
(#9)
Old
ahmadlou ahmadlou is offline
Junior Member
ahmadlou is on a distinguished road
 
Posts: 5
Join Date: Mar 2015
Default 03-10-2015, 12:04 PM

Quote:
Originally Posted by DanielNichesite3 View Post
If you're using wordpress now. It's quite simple. Go to settings > general > change the link to http://www.yoursite.com
I'm not using WordPress but thanks for your help.
Reply With Quote
(#10)
Old
losakaniroshan losakaniroshan is offline
Senior Member
losakaniroshan is on a distinguished road
 
Posts: 271
Join Date: Jul 2012
Location: UK
Default 03-10-2015, 02:44 PM

Quote:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.yourdomain.com$ [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
I am using this code for my sites.I really don't know bout coding but it is working fine for me and it will work for you too...
Reply With Quote
Reply

Tags
force, redirect, visitors, www

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com