SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    May 2007
    Location
    West Coast
    Posts
    336
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with htaccess

    It works at probably 98% of hosts but not Godaddy on a linux hosted server.In fact, it was working until we moved hosts.

    Code:
    Options +FollowSymLinks
    
    RewriteBase /site.com
    RewriteEngine On
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html?\ HTTP/
    RewriteRule ^index\.html$ http://www.site.com/ [R=301,L]
    RewriteCond %{HTTP_HOST} ^site.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.site.com$
    RewriteRule (.*)$ http://www.site.com/$1 [R=301,L]
    
    ////////  RIGHT NOW ONLY the 3 line code below is working /////////
    
    DirectoryIndex index.php index.html
    
    ErrorDocument 404 /404.shtml
    #RewriteRule ^/?([a-z]+)$ $1.html [L]
    I was told the above would work but it gives a 500 server error

    All I want to do is get rid of the index.html extension on the home page.

    Also, it has a 404.shtml page

    I do have the rel="canonical" but aesthetically I want that index.html to not display.

    any tips?

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,604
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    lukkas,

    Several years ago GoDaddy did not allow access to the .htaccess file nor use of mod_rewrite. That's the penalty for using a notoriously BAD host (but excellent registrar?).

    As for your code:

    Code:
    Options +FollowSymLinks
    // Should be in the host's httpd.conf file, i.e., not needed
    
    RewriteBase /site.com
    // before RewriteEngine on? 
    // Okay, this should NEVER be used for a domain, only for folders within the website!
    // It may be the cause of your 500 error.
    
    RewriteEngine On
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html?\ HTTP/
    RewriteRule ^index\.html$ http://www.site.com/ [R=301,L]
    // Why? Some hosts may force display of the DirectoryIndex filename.
    // Okay, this is probably a "personal thing" with me rather than an error.
    
    RewriteCond %{HTTP_HOST} ^site.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.site.com$
    RewriteRule (.*)$ http://www.site.com/$1 [R=301,L]
    // LOOPY! If www.site.com then redirects to www.site.com!?!
    
    
    ////////  RIGHT NOW ONLY the 3 line code below is working /////////
    // Technique: Apache core directives are ALWAYS executed before mod_rewrite
    // so I put these at the top of my .htaccess file.
    
    DirectoryIndex index.php index.html
    
    ErrorDocument 404 /404.shtml
    #RewriteRule ^/?([a-z]+)$ $1.html [L]
    // IF mod_rewrite is available, this will allow extensionless page names.
    Well, only the RewriteBase and loopy code should cause problems so comment out both then uncomment one at a time to determine your offending line ... AFTER you confirm that GoDaddy has enabled mod_rewrite and uses .htaccess files (configurable in httpd.conf).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,625
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

  4. #4
    SitePoint Addict
    Join Date
    May 2007
    Location
    West Coast
    Posts
    336
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Dave,

    I told them not to use GoDaddy but that is what he wants. GoDaddy declined to help after he was on the phone for 30 minutes.

  5. #5
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,598
    Mentioned
    411 Post(s)
    Tagged
    6 Thread(s)
    Off Topic:

    Quote Originally Posted by lukkas View Post
    that is what he wants.
    Then that means he doesn't want to hide index.html. Simple.

  6. #6
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,604
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by lukkas View Post
    Thanks Dave,

    I told them not to use GoDaddy but that is what he wants. GoDaddy declined to help after he was on the phone for 30 minutes.
    At least HE wasted his time with GoDaddy, not you!

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Tags for this Thread

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
  •