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.


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?

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:


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

Here is what I use http://www.visibilityinherit.com/code/canonicalization-htaccess-mod_rewrite-301-redirect-non-www-to-www-and-index-to-folder.php

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.

Off Topic:

Then that means he doesn’t want to hide index.html. Simple. :slight_smile:

:smiley: :smiley: :smiley: At least HE wasted his time with GoDaddy, not you!

Regards,

DK