Current location: Hot Scripts Forums » Other Discussions » Web Servers » [SOLVED] 301 redirect using .htaccess


[SOLVED] 301 redirect using .htaccess

Reply
  #1 (permalink)  
Old 02-25-09, 03:00 PM
Frogger Frogger is offline
Wannabe Coder
 
Join Date: Jul 2006
Posts: 149
Thanks: 5
Thanked 0 Times in 0 Posts
[SOLVED] 301 redirect using .htaccess

Hi,

I am trying to use 301 redirect using .htaccess to help with my SEO.
I have looked around the internet and everything I try just doesnt seem to work.
I want all various link to be redirected to http://www.frogger.com.au/

This is what I have done but for some reason it just doesnt work.
Any ideas ?

Code:
Redirect 301 http://frogger.com.au http://www.frogger.com.au/
Redirect 301 http://frogger.com.au/ http://www.frogger.com.au/
Redirect 301 http://frogger.com.au/index.html http://www.frogger.com.au/
Redirect 301 http://www.frogger.com.au/index.html http://www.frogger.com.au/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 03-01-09, 02:41 AM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,167
Thanks: 3
Thanked 8 Times in 8 Posts
I think its because of the first "http". Try "index.html" instead of http://frogger.com.au/index.html for example.


Pete
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 03-01-09, 03:22 PM
Frogger Frogger is offline
Wannabe Coder
 
Join Date: Jul 2006
Posts: 149
Thanks: 5
Thanked 0 Times in 0 Posts
I tried doing the below as you said but I still dont get any redirection.

Code:
Redirect 301 index.html http://www.frogger.com.au/
Redirect 301 http://frogger.com.au http://www.frogger.com.au/
Redirect 301 http://frogger.com.au/ http://www.frogger.com.au/
Redirect 301 http://www.frogger.com.au/index.html http://www.frogger.com.au/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 03-03-09, 01:08 AM
drowzee drowzee is offline
Newbie Coder
 
Join Date: Dec 2008
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Flogger,

Have you tried Rewrite?

http://httpd.apache.org/docs/1.3/misc/rewriteguide.html

Code:
Description:
    The goal of this rule is to force the use of a particular hostname, in preference to other hostnames which may be used to reach the same site. For example, if you wish to force the use of www.example.com instead of example.com, you might use a variant of the following recipe.
Solution:

    # For sites running on a port other than 80
    RewriteCond %{HTTP_HOST}   !^fully\.qualified\.domain\.name [NC]
    RewriteCond %{HTTP_HOST}   !^$
    RewriteCond %{SERVER_PORT} !^80$
    RewriteRule ^/(.*)         http://fully.qualified.domain.name:%{SERVER_PORT}/$1 [L,R]

    # And for a site running on port 80
    RewriteCond %{HTTP_HOST}   !^fully\.qualified\.domain\.name [NC]
    RewriteCond %{HTTP_HOST}   !^$
    RewriteRule ^/(.*)         http://fully.qualified.domain.name/$1 [L,R]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 03-03-09, 01:31 AM
Frogger Frogger is offline
Wannabe Coder
 
Join Date: Jul 2006
Posts: 149
Thanks: 5
Thanked 0 Times in 0 Posts
Thanks for reply

This seems to work now:

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^frogger\.com.au$ [NC]
RewriteRule ^(.*)$ http://www.frogger.com.au/$1 [R=301,L]
But how do I get the index.html to redirect ie:

http://frogger.com.au ---> 301 redirect to ---> http://www.frogger.com.au/


http://frogger.com.au/ ---> 301 redirect to ---> http://www.frogger.com.au/


http://frogger.com.au/index.html ---> 301 redirect to ---> http://www.frogger.com.au/
http://www.frogger.com.au ---> 301 redirect to ---> http://www.frogger.com.au/


http://www.frogger.com.au/ - Canonical URL (no redirect)


http://www.frogger.com.au/index.html ---> 301 redirect to ---> http://www.frogger.com.au/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 03-03-09, 01:36 AM
drowzee drowzee is offline
Newbie Coder
 
Join Date: Dec 2008
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Try to add this after rewrite rules:

Code:
Redirect 301 /index.html http://www.frogger.com.au/
Works fine for me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 03-03-09, 01:54 PM
Frogger Frogger is offline
Wannabe Coder
 
Join Date: Jul 2006
Posts: 149
Thanks: 5
Thanked 0 Times in 0 Posts
Thanks drowzee. I added the below but for some reason the site just hangs and doesnt load the page.


Code:
Redirect 301 /index.html http://www.frogger.com.au/
RewriteEngine On
RewriteCond %{HTTP_HOST} ^frogger\.com.au$ [NC]
RewriteRule ^(.*)$ http://www.frogger.com.au/$1 [R=301,L]
works ok with out
Code:
Redirect 301 /index.html http://www.frogger.com.au/
But I am left without
http://frogger.com.au/index.html ---> 301 redirect to ---> http://www.frogger.com.au/

http://www.frogger.com.au/index.html ---> 301 redirect to ---> http://www.frogger.com.au/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 03-04-09, 07:13 AM
drowzee drowzee is offline
Newbie Coder
 
Join Date: Dec 2008
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Frogger,

Hm... try to put that Redirect after all RewriteRule lines.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 03-04-09, 02:21 PM
Frogger Frogger is offline
Wannabe Coder
 
Join Date: Jul 2006
Posts: 149
Thanks: 5
Thanked 0 Times in 0 Posts
hi drowzee,

thanks for your help. after playing aroudn with it for a few hours i finally worked it out using below. thanks again for your help.

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^frogger\.com.au$ [NC]
RewriteRule ^index\.html$ http://www.frogger.com.au/$1 [R=301,L]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
.htaccess 301 redirect MikeW Web Servers 3 08-30-08 05:40 AM
[SOLVED] .htaccess 301 redirect snaip Web Servers 12 03-09-08 11:15 AM
Really complex redirect 301 - need help! Josie ASP 2 07-08-06 05:22 PM
Permanent 301 Redirect to new Domain's URL giving me problems in .htaccess cebuy HTML/XHTML/XML 1 03-10-06 11:34 PM
.htaccess and PHP Redirect problem dodod PHP 3 06-19-05 11:56 PM


All times are GMT -5. The time now is 09:53 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.