Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 10th Feb 2012, 03:58 AM   #1
Active Warrior
 
Join Date: 2011
Posts: 73
Thanks: 26
Thanked 7 Times in 7 Posts
Default
.htaccess help
Share on: 
fb share twitter share gplus share more share

Hey,

Can someone please help me with making a .htaccess file that does these 2 things:
In order to preserve page rank, I believe this is beneficial, but not sure. Anyway, I'd like to have it this way, so visitors always land on http://www.example.com

The code below does this, but there's a problem. It only works on the primary domain on my hosting account (hostgator). If I try to put in on an addon domain, i.e. a separate domain name but on the same hosting account, it doesn't work. It screws up my main domain.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1[R=301,L]
RewriteCond %{THE_REQUEST} /index\.html [NC]
RewriteRule ^(.*/)?index\.html$ /$1 [R=301,L]
RewriteRule ^(.+)/$ /$1 [R=301,L]

Anyone know how to make this work on an addon domain in a hostgator account?

Btw, if you want to swipe the code above, feel free. It's pretty nice.
marmalade is offline  
Unread 10th Feb 2012, 05:49 AM   #2
Active Warrior
 
Join Date: 2011
Posts: 73
Thanks: 26
Thanked 7 Times in 7 Posts
Default
Re: .htaccess help
Share on: 
fb share twitter share gplus share more share

I resolved this. I think it's working because on the addon domain I have index.PHP but on the main domain I have index.HTML.
marmalade is offline  
Unread 10th Feb 2012, 09:22 AM   #3
Developer
War Room Member
 
K Meier's Avatar
 
Join Date: 2011
Location: Dublin, Ireland
Posts: 363
Thanks: 5
Thanked 48 Times in 47 Posts
Default
Re: .htaccess help
Share on: 
fb share twitter share gplus share more share

Originally Posted by olalinks View Post

Are you serious ?
It's too simple.
U can use html redirect code
Like this :


Content=5 : means your site will be redirected in 5 seconds
url=: means the target site .


Paste this code to your <head> ///// code here /// </head>
Meta redirects are the most unreliable ones, as they can be interrupted by the browser. Also you're not telling any crawlers or search engine that it should be a permanent 301 redirect.
Another alternative would be a PHP redirect, however .htaccess redirects are the most reliable ones.
K Meier is offline  
Unread 10th Feb 2012, 10:50 AM   #4
Advanced Warrior
War Room Member
 
micksss's Avatar
 
Join Date: 2008
Location: New England
Posts: 753
Thanks: 89
Thanked 100 Times in 93 Posts
Default
Re: .htaccess help
Share on: 
fb share twitter share gplus share more share

I agree 301 redirect in .htaccess is the recommended SEO way of doing this.

Web Hosting Reviews ► www.CastironHosting.com ◄ Read or Submit Feedback on Web Hosts.
Web Hosting Coupons, Deals & Promos!

Need a Virtual Private Server? www.VPSPlan.com
micksss is offline  
Closed Thread


Bookmarks

Tags
htaccess


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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 05:50 PM.