Go Back   HostGator Peer Support Forums > Public Forums > Pre-Sales Questions

Notices

Reply
 
Thread Tools
  #1  
Old 04-13-2008, 10:26 PM
Savage21's Avatar
Savage21 Savage21 is offline
Hatchling Croc
 
Join Date: Apr 2008
Location: Long Island, New York.
Posts: 23
Default Need Help: Always Have 'www.' in URL

Hi, I just purchased the Baby package from HostGator.

I am trying to figure out how to always have 'www.' in my website's URL (ie: http://HostGator.com will take you to http://www.HostGator.com).

I'm sure it's simple, but I cannot seem to figure it out. Also, where do I upload my files? I added my own 'index.html' page in my 'www' directory, but when I go to my domain it still goes to the HostGator default page. I need to go to 'mydomain.com/index.html/' in order to view my page.

Thanks. P.S. Would someone mind approving my forum account? I'm sure there is a better place for this thread once I can view the whole forum.
Reply With Quote
  #2  
Old 04-13-2008, 11:16 PM
Savage21's Avatar
Savage21 Savage21 is offline
Hatchling Croc
 
Join Date: Apr 2008
Location: Long Island, New York.
Posts: 23
Default Re: Need Help: Always Have 'www.' in URL

I accidently deleted 'public_html' and when I re-uploaded it I am getting a 403 Forbidden message. What's wrong?
Reply With Quote
  #3  
Old 04-13-2008, 11:20 PM
GatorZach
HostGator Guest
 
Posts: n/a
Default Re: Need Help: Always Have 'www.' in URL

If you deleted your public_html folder, then you'll need to place a ticket, to have the following done:

cd /home/savage21
chmod 0750 public_html
chown savage21.nobody public_html
Reply With Quote
  #4  
Old 04-14-2008, 12:00 AM
slapshotw's Avatar
slapshotw slapshotw is offline
Veteran Croc
 
Join Date: Jun 2006
Posts: 5,163
Default Re: Need Help: Always Have 'www.' in URL

As far as your first two questions go--to force www, put this in your .htaccess:

Code:
RewriteCond  %{HTTP_HOST}  ^DOMAIN\.com [NC]
RewriteRule  ^/?(.*)  http://www.DOMAIN\.com/$1 [R=301,L]
Make sure to replace DOMAIN.com with your own domain.

For the second one, delete the "default.html" or "default.php" file from your account, and index.html should automatically become the default.
__________________
Follow me on Twitter! http://twitter.com/mrw
Reply With Quote
  #5  
Old 04-14-2008, 11:22 AM
Savage21's Avatar
Savage21 Savage21 is offline
Hatchling Croc
 
Join Date: Apr 2008
Location: Long Island, New York.
Posts: 23
Default Re: Need Help: Always Have 'www.' in URL

I submitted a ticket last night and they fixed it for me.

I'll try the .htaccess thing when I get home, slapshotw. And I think the index problem is fixed as well. Thanks.

One more question: If I recall correctly, I don't have a .htaccess in my files. Do I just create a page with the code you gave me and name it .htaccess?
Reply With Quote
  #6  
Old 04-14-2008, 11:47 AM
Catastrophii Catastrophii is offline
Hatchling Croc
 
Join Date: Apr 2008
Posts: 5
Default Re: Need Help: Always Have 'www.' in URL

.htaccess is (or should be) in your public_html folder.

Here is a little tutorial on what htaccess is and how to edit it. :3

htaccess Tutorial

Good luck. :]
Reply With Quote
  #7  
Old 04-14-2008, 02:26 PM
Savage21's Avatar
Savage21 Savage21 is offline
Hatchling Croc
 
Join Date: Apr 2008
Location: Long Island, New York.
Posts: 23
Default Re: Need Help: Always Have 'www.' in URL

When I uploaded .htaccess to the public_html folder it said I already have that file and asked if I wanted to override it. I don't see it though?
Reply With Quote
  #8  
Old 04-14-2008, 02:28 PM
GatorZach
HostGator Guest
 
Posts: n/a
Default Re: Need Help: Always Have 'www.' in URL

If you're going through File Manager, then you might not have ticked the 'show hidden files' checkbox that would allow you to see those types of files.
Reply With Quote
  #9  
Old 04-14-2008, 03:27 PM
Savage21's Avatar
Savage21 Savage21 is offline
Hatchling Croc
 
Join Date: Apr 2008
Location: Long Island, New York.
Posts: 23
Default Re: Need Help: Always Have 'www.' in URL

Thanks. I found it and added the code but when I go to my site without www. it still doesn't add it.
Reply With Quote
  #10  
Old 04-14-2008, 04:01 PM
GatorZach
HostGator Guest
 
Posts: n/a
Default Re: Need Help: Always Have 'www.' in URL

Try this code:

Quote:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301]
Reply With Quote
  #11  
Old 04-14-2008, 04:10 PM
Savage21's Avatar
Savage21 Savage21 is offline
Hatchling Croc
 
Join Date: Apr 2008
Location: Long Island, New York.
Posts: 23
Default Re: Need Help: Always Have 'www.' in URL

Thanks mate, works great.

Edit: Sorry for the trouble, but when I go to 'mydomain.com/forum' it doesn't seem to add the www. part.

Last edited by Savage21; 04-14-2008 at 04:14 PM.
Reply With Quote
  #12  
Old 04-14-2008, 04:30 PM
GatorZach
HostGator Guest
 
Posts: n/a
Default Re: Need Help: Always Have 'www.' in URL

After commenting out /forum/.htaccess, it works now. It was overriding the parent .htaccess
Reply With Quote
  #13  
Old 04-14-2008, 04:43 PM
Savage21's Avatar
Savage21 Savage21 is offline
Hatchling Croc
 
Join Date: Apr 2008
Location: Long Island, New York.
Posts: 23
Default Re: Need Help: Always Have 'www.' in URL

Thanks, now it works.

But wherever I go on my site I get a 500 Internal Server Error. What happened?
Reply With Quote
  #14  
Old 04-14-2008, 04:58 PM
GatorZach
HostGator Guest
 
Posts: n/a
Default Re: Need Help: Always Have 'www.' in URL

.htaccess was broke, had a '#' right after a rule where you had Begin Wordpress, was messing it up.

Fixed.
Now ya just gotta work on your public_html/
Reply With Quote
  #15  
Old 04-14-2008, 05:23 PM
Savage21's Avatar
Savage21 Savage21 is offline
Hatchling Croc
 
Join Date: Apr 2008
Location: Long Island, New York.
Posts: 23
Default Re: Need Help: Always Have 'www.' in URL

Thanks.

WordPress didn't seem to work. Actually, WordPress was apearently the cause of that. Is it safe to try to reinstall WordPress again? Something was failing to upload the first time, but I was able to setup an account for myself. It wasn't until I went to the wp-login page that I got the error.
Reply With Quote
  #16  
Old 04-14-2008, 05:30 PM
GatorZach
HostGator Guest
 
Posts: n/a
Default Re: Need Help: Always Have 'www.' in URL

I'd take out those rules for a sec, install wordpress, then append the rules back to the end of that file, that should fix it.
Reply With Quote
  #17  
Old 04-14-2008, 05:49 PM
Savage21's Avatar
Savage21 Savage21 is offline
Hatchling Croc
 
Join Date: Apr 2008
Location: Long Island, New York.
Posts: 23
Default Re: Need Help: Always Have 'www.' in URL

Yup, I'm all set now. Thanks again for all the help.
Reply With Quote
  #18  
Old 05-06-2008, 03:29 PM
dias dias is offline
Hatchling Croc
 
Join Date: May 2008
Posts: 1
Default Re: Need Help: Always Have 'www.' in URL

Hey!
No need to uninstall/reinstall WP.
Just go to Setting/General and change WordPress address (URL) and Blog address (URL) sections.For example: http://domain.com/wp >> http://www.domain.com/wp
Reply With Quote
  #19  
Old 05-07-2008, 06:17 PM
sersuesp sersuesp is offline
Hatchling Croc
 
Join Date: Jan 2007
Location: Mexico
Posts: 23
Default Re: Need Help: Always Have 'www.' in URL

what if i dun want to have the www ?? Because i need all my urls go to https://mydomain.com

Thanks.
Reply With Quote
  #20  
Old 05-08-2008, 04:06 PM
Cadinos's Avatar
Cadinos Cadinos is offline
Hatchling Croc
 
Join Date: Sep 2007
Location: Utah
Posts: 15
Default Re: Need Help: Always Have 'www.' in URL

should be the same as the other code posted here except the www is in RewriteCond and not RewriteRule. (You may have to change http to https if you want it for https)
e.g.:
Code:
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
Reply With Quote
  #21  
Old 06-17-2008, 07:34 AM
infra-greg infra-greg is offline
Hatchling Croc
 
Join Date: Jun 2008
Posts: 4
Default Re: Need Help: Always Have 'www.' in URL

hi guys

i've got a similar problem but with Joomla.

Its in a subdirectory, so its www.mydomain.com/joomla

If i type www.mydomain.com/joomla I get http://mydomain.com/joomla

So I played with the above code in my .htaccess file. And got some success but not completely. ie:

1. If I type www.mydomain.com/joomla/ (with backslash at the end) it works fine.

2. But if there is no backslash at the end, then its back to http://mydomain.com/joomla

3. Also, if i just type http://mydomain/joomla, then it stays the same. (no big deal, but I would prefer for it to work for (1) and (2) above

I've added the code to:

1. Just the htaccess file in public html
2. Just to htaccess in Joomla directory
3. To both htaccess files

All 3 ways yield the same results.

One other things to note:

My joomla configuration file ihas the live url set correctly. ie http://www.mydomain.com/joomla

Anyone have any tips?

Thanks
Reply With Quote
  #22  
Old 06-17-2008, 08:46 AM
ghpk ghpk is offline
King Croc
 
Join Date: Nov 2006
Posts: 1,238
Default Re: Need Help: Always Have 'www.' in URL

infra-greg, what code you are using in .htaccess ?
Reply With Quote
  #23  
Old 06-17-2008, 09:05 AM
infra-greg infra-greg is offline
Hatchling Croc
 
Join Date: Jun 2008
Posts: 4
Default Re: Need Help: Always Have 'www.' in URL

hey ghpk

this is the full htaccess code in my joomla directory with the code mentioned earlier in this thread (in red below)

Code:
##  Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

#
#  mod_rewrite in use

RewriteEngine On



RewriteCond  %{HTTP_HOST}  ^mydomain/joomla\.com [NC]
RewriteRule  ^/?(.*)  http://www.mydomain/joomla\.com/$1 [R=301,L]



#  Uncomment following line if your webserver's URL
#  is not directly related to physical file paths.
#  Update Your Joomla!/MamboDirectory (just / for root)

# RewriteBase /


########## Begin - Joomla! core SEF Section
############# Use this section if using ONLY Joomla! core SEF
## ALL (RewriteCond) lines in this section are only required if you actually
## have directories named 'content' or 'component' on your server
## If you do not have directories with these names, comment them out.
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR]         ##optional - see notes##
RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$  [NC]
RewriteRule ^(content/|component/) index.php
#
########## End - Joomla! core SEF Section



########## Begin - 3rd Party SEF Section
############# Use this section if you are using a 3rd party (Non Joomla! core) SEF extension - e.g. OpenSEF, 404_SEF, 404SEFx, SEF Advance, etc
#
#RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR]         ##optional - see notes##
#RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$  [NC]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule (.*) index.php
#
########## End - 3rd Party SEF Section



########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits
Reply With Quote
Reply

Bookmarks

Thread Tools

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 Off
HTML code is Off

Forum Jump

All times are GMT -6. The time now is 10:31 PM.

 
Forum SEO by Zoints