Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Page 1 of 2 12 LastLast
Results 1 to 15 of 18

This is a discussion on htaccess redirect question in the Shared & Semi-Dedicated forum
I just got WordPress installed and running on my site (I was using Greymatter). WordPress is some tasty software. Anyway, my site's home page used ...

  1. #1
    Loyal Client
    Join Date
    May 2002
    Location
    Wisconsin, USA
    Posts
    568

    htaccess redirect question

    I just got WordPress installed and running on my site (I was using Greymatter). WordPress is some tasty software.

    Anyway, my site's home page used to be index.html and now it's index.php and I want to make sure anyone that goes to http://mysite.com/index.html gets redirected to the new page. I've been playing around with various rewrite commands like:

    Redirect /index.html /index.php
    Redirect http://mysite.com/index.html http://mysite.com//index.php

    and all I'm getting are error messages. I'm obviously not doing something right and after reading through some of the tutorials on .htaccess my brain is fried. What am I doing wrong?

  2. #2
    Loyal Client
    Join Date
    May 2002
    Location
    Wisconsin, USA
    Posts
    568
    One more question...

    Is is possible to redirect to the root instead of index.php?

  3. #3
    || $name ne 'R.Stiltskin'
    Join Date
    Jun 2003
    Location
    Tejas
    Posts
    2,438
    Code:
    # Enable mod_rewrite
    RewriteEngine On
    
    # Set a basic rule
    RewriteRule ^index.html index.php    [NC]
    
    # or
    
    # Set a basic rule for "root"
    RewriteRule ^index.html /    [NC]
    Last edited by Spathiphyllum; 06-24-2005 at 01:35 PM. Reason: Typo

  4. #4
    || $name ne 'R.Stiltskin'
    Join Date
    Jun 2003
    Location
    Tejas
    Posts
    2,438
    How permanent do you want to indicate such redirects, if at all? You may want to tweak it to say "temporary" or "permanent" or something else. As it is, it just returns a "200 OK" response header, which is fine but may not be exactly what you want.

  5. #5
    coin operated boy Rye Seronie Oh's Avatar
    Join Date
    Mar 2005
    Location
    Crosby, TX
    Posts
    125
    Why not a simple

    Code:
    RedirectPermanent index.html /index.php
    No mod_rewrite required.
    Ryan Ottele
    Web: http://www.sparkeh.com/
    Mail: ryan.ottele[[@]]gmail.com

  6. #6
    JPC Member Percipient's Avatar
    Join Date
    Sep 2001
    Location
    BC, Canada
    Posts
    11
    Quote Originally Posted by JonathanB
    Redirect /index.html /index.php
    Redirect http://mysite.com/index.html http://mysite.com//index.php
    You need a combination of these, and a number.

    Code:
    Redirect 301 /index.html http://mysite.com/index.php
    You can refer to the Apache manual on the redirect directive.

    Basically, the number is the type of redirect. In my example, 301 is a permanant, so search engines will start indexing the new content and scrapping the old page. You could probably also use 303, which is a seeother status, indicating that the resource has been replaced. Not sure how well that one works though. 301 is good.

    Next is the old file name, relative to your domain. note the starting slash.

    The last is the redirect destination, which must be an absolute URL, even if the file's on your own site.

    Quote Originally Posted by JonathanB
    One more question...

    Is is possible to redirect to the root instead of index.php?
    Yes.

    Code:
    Redirect 301 /index.html http://mysite.com/
    Hope that helps you.
    Last edited by Percipient; 06-24-2005 at 02:03 PM.
    Edward Rands

  7. #7
    Old Hillbilly Connie's Avatar
    Join Date
    Sep 2001
    Location
    Hills of Missouri
    Posts
    2,648
    Avoid 302 redirects. Google in particular has problems with them.

    Forum Moderators - Jag Staff

    Spam Whackers Blog - Dedicated to fighting Spam and providing General SEO Tips
    Organize your Kitchen or purchase Kitchen Accessories at Condells
    Ihelpyou Forum - Dedicated to "Best Practices" SEO

  8. #8
    Loyal Client
    Join Date
    May 2002
    Location
    Wisconsin, USA
    Posts
    568
    Thanks for all the help guys. I did try a few of the suggestions and I'm still getting error messages like:

    Redirection limit for this URL exceeded.
    There was a pretty long list of mod_rewrite rules I added to my .htaccess file so the permalink structure would be clean and friendly like:

    http://example.com/archives/2005/6/24/post-title

    I think that's probably what's interfering with the redirection I'm trying to do.

    For now I've set up my custom 404 page to direct visitors to the right spot. I'll think I'll watch the error log file and see if there are lot of people going to the index.html file or not.

  9. #9
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,775
    Redirection limit for this URL exceeded.
    Heh! That means you're stuck in a friggin' loop! After x-number of redirections, it gives up (thank God)...

    I'd be inclined to try:
    Code:
    Redirect 301 /index.html  http://mysite.com/index.php
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL © 2010

  10. #10
    the Windlord Gwaihir's Avatar
    Join Date
    Jun 2002
    Posts
    2,562
    Quote Originally Posted by JonathanB
    There was a pretty long list of mod_rewrite rules I added to my .htaccess file so the permalink structure would be clean and friendly like:

    http://example.com/archives/2005/6/24/post-title

    I think that's probably what's interfering with the redirection I'm trying to do.
    In that case, I would suggest you use the mod_rewrite way of solving this problem (as suggested first).

    While the guys (m/f) are right that the redirect method is, by itself, a simpler way of solving the question asked, I do think it's best to avoid using both redirect and mod_rewrite in one place. As the first isn't elaborate enough for you (can't do that "clean and friendly" thing), best to now do all your rewriting / redirecting with the latter.
    Regards,

    Wim Heemskerk
    ---
    Visit MeCCG.net - Cardgaming in J.R.R. Tolkien's Middle-earth
    And Gwaihir.net - The Middle-earth CCG store

  11. #11
    Loyal Client
    Join Date
    May 2002
    Location
    Wisconsin, USA
    Posts
    568
    You're absolutely right Gwaihir, I scrapped the redirect statement and used the rewrite Spathiphyllum mentioned near the top of this thread, and that did the trick.

    Now if I just would have listened to Spath when he first suggested that...

    Thanks guys!

  12. #12
    Loyal Client
    Join Date
    May 2002
    Location
    Wisconsin, USA
    Posts
    568
    Quote Originally Posted by Spathiphyllum
    How permanent do you want to indicate such redirects, if at all? You may want to tweak it to say "temporary" or "permanent" or something else. As it is, it just returns a "200 OK" response header, which is fine but may not be exactly what you want.
    Okay, I just realized I forgot the issue about it being a permanent change.

    After reading a few .htaccess sites, I think I should use the below statement, right?

    RewriteRule ^index.html / [R=301]

  13. #13
    || $name ne 'R.Stiltskin'
    Join Date
    Jun 2003
    Location
    Tejas
    Posts
    2,438
    Quote Originally Posted by JonathanB
    ...After reading a few .htaccess sites, I think I should use the below statement, right?

    RewriteRule ^index.html / [R=301]
    Yes, that syntax is correct to indicate a 301 redirect. The "NC" can be added if you want to disregard case for any derived URL:
    Code:
    RewriteRule ^index.html / [NC,R=301]
    Note from mod_rewrite that "when you use this flag, make sure that the substitution field is a valid URL! If not, you are redirecting to an invalid location! And remember that this flag itself only prefixes the URL with http://thishost[:thisport]/, rewriting continues. Usually you also want to stop and do the redirection immediately. To stop the rewriting you also have to provide the 'L' flag."

    What does this mean? Try:
    Code:
    RewriteRule ^index.html / [NC,R=301,L]
    to end the rewrites and URL processing as soon as the rule has been successfully applied. It should speed things up a little bit and might eliminate confusion from other chains beyond that rule.

  14. #14
    Loyal Client
    Join Date
    May 2002
    Location
    Wisconsin, USA
    Posts
    568
    Quote Originally Posted by Spathiphyllum
    Try:
    Code:
    RewriteRule ^index.html / [NC,R=301,L]
    to end the rewrites and URL processing as soon as the rule has been successfully applied. It should speed things up a little bit and might eliminate confusion from other chains beyond that rule.
    When I read about the L rule on those .htaccess websites, I got confused and didn't want to mess up the WordPress rules below that in the .htaccess file.

    So you're saying if the system runs the above rule, it will stop after that rule and not run any rules in the .htaccess file after that. If it doesn't run the above rule, it will continue on to the other rules below. Is that right?

  15. #15
    Ron
    Ron is online now
    Loyal Client
    Join Date
    Aug 2002
    Posts
    7,307
    Yes. But remember, after the redirect, it will be coming back and be subject to all of your rules again.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •