Skip to Content
Register · Login
About Theme

A Letterboxing Community

Atlas Quest
Search Edit Search

Read Thread: Fun with .htaccess (NOT!)

Fun with .htaccess (NOT!)
Board: Designing and Creating Webpages
Aug 22, 2013 4:06pm
Thread (disabled) Board
I ran into something weird that I don't completely understand and am wondering if anyone out there has an inkling...

So I have a hosting account for my own business and host a bunch of subdomains (for my clients). I was checking on things and realized that I probably still have some link juice going to my old home page (index.htm) which has been renamed to index.html.

So I altered my (main site) .htaccess file, as follows, with the last line.

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.integritivity\.com
RewriteRule (.*) http://www.integritivity.com/$1 [R=301,L]
ErrorDocument 404 http://integritivity.com/notfound.html
Redirect 301 /index.htm http://www.integritivity.com/index.html

After checking some other stuff and putting www rewrite rules into some old clients' .htaccess files that didn't have them, I discovered that I had somehow broken two of my subdomains.

The rest of them, however, were just fine. I spent hours trying to find the differences.
www.thefoundationagency.com, for instance, has a RewriteEngine off and works just fine.
www.mattressprosstl.com has rewrite rules similar to the above and it works fine, too.

After giving up on the idea that the .htaccess files on the subdomains had anything to do with it, I decided to go back to the main .htaccess file and see if any of my changes to it had caused the issues.

As it turns out, that last line I added (Redirect 301) was it. (I had added some other page redirects too, but they are irrelevant.) AHA, the only two broken sites were old ones that still have .htm extensions. All my newer ones use .html (or .php). One of the sites that had "broken" had it's own index.htm for the home page. So it was being redirected back to my main site. OK, that makes sense (now). The other one has a default.htm (I took this one over from someone else). So I'm not really sure why that one had an issue.

My guess is that it's because maybe the host reads it as default.htm but treats it as index.htm?

QUESTION TWO
So given that I found the problem line (and toggled it on and off to make sure), I thought I'd fix it.
I changed the faulty line to
Redirect 301 http://www.integritivity.com/index.htm http://www.integritivity.com/index.html
since I really do want to save that link juice.
This change did not break anything.
However, if I try to go to http://www.integritivity.com/index.htm, I get notfound instead of the .html version!

So it must be the syntax of including an entire URL in the 301 line, yet I don't know what it is.

Any ideas? Ready for a margarita? Ya, me, too.