Apache Web Server Forum

I've had my .htaccess file work perfectly for years on my GoDaddy Linux hosting. I've made no real changes, but just a few hours ago I discovered that all my redirects are creating 404 errors in all my browsers.

So I reduced my .htaccess file to it's most basic format and I can't even get this working:

When I got to www.example.com/about.html, it will not redirect to www.google.com. Should it? Is there something wrong with my syntax? The first 2 rules work just fine, but the 301 redirect at the end doesn't do it's job.

I've tried so many different things, I'm at a loss. Any help would be appreciated!

The geeks at GoDaddy messed up big time likely at the time when they migrated their servers to Apache 2.4 in the last month.

On their grid hosting plan you now have to specify the folder your website is located in, when you make a relative path. Unbelievable. One day you wake up and everything that all the websites that were working for 5 years are broken. No notification, no warning. Thousands of dollars down the drain.

So now

Redirect /path.html http://example.com/correctpath.html

has to be written like this:

Redirect /foldername/path.html http://example.com/correctpath.html

<sigh>Now that I changed all my redirects, I'll have to constantly test that they don't change it all back the way it was.</sigh>

You've got mod_rewrite and mod_alias in the same htaccess. This can be perilous. Take any rules using mod_alias (Redirect by that name) and translate them to mod_rewrite form.

The bad news is that I don't see any way that this would affect your present situation.

Is the redirect to google just for experimental purposes so you can see things happening in the browser? You can achieve the same result by redirecting to a nonsense page like "foobar.html". Your screen will show your 404 page, but the browser's address bar will show example.com/foobar.html. Try it, anyway. It's remotely possible that some new server setting is interfering with off-site redirects. (It shouldn't, of course, but that's a separate problem once you've got it diagnosed.)

all my redirects are creating 404 errors in all my browsers

It would be a ### of a lot more worrying if there were errors in some browsers but not all of them. The only time you'll see browser-specific behavior is if you repeat a request that was previously redirected; then the browser may remember the redirect and won't try a fresh request.

When did the problem start? On shared hosting you may not have access to many days' worth of raw logs. (Mine defaults to 3; I changed it to 15 to give me more time to remember to get everything downloaded.)

The rules you've got are perfectly innocuous except for minor points like (a) mixing mod_alias and mod_rewrite (b) the three rules are in the precise opposite order to what they should be: you should go from individual page redirects, to redirects following a pattern, and then the "index.html" redirect and the domain-name canonicalization should be the very last two rules (c) the form ^example.com is imperfect in several ways; it should ideally be !^(www\.example\.com)?$ (d) the expression .* should never be used in mid-pattern if you can possibly help it. If you can't get by with a simple %{THE_REQUEST} index\.html then use /([^/]+/)*index\.html

But all of this is minor spit-and-polish that should not prevent anything from working.

I've made no real changes, but

Mm, yes, it's the "but" that causes alarm.

Do you realize that you never explained the 404 errors? Was that purely a reference to requests for a nonexistent "about.html"?

Did mod_alias (Redirect by that name) work at some time in the past? It's not likely your host has changed Override settings. Those govern behaviors rather than specific modules and I don't think there's any way you could use mod_rewrite while not being able to use mod_alias. And if the server's mod_alias was broken, I think even GoDaddy would tell you.

Thank-you very much for your reply lucy. I entered my solution as soon as I discovered it. Now we're both sorry it wasn't sooner. :S

Yes, the redirect was just for experimental purposes. I could have made that clearer.

Yes, having mod_rewrite and mod_alias directives together can cause issues - none that I've experienced, but I've read they can get in each other's way.

Wow, you are sharp... I didn't realize that my my mention of 404 errors wasn't consistent with the example code that I provided, but you caught it. The 404 errors were because some of my redirects weren't actual files names. In the above code however, the redirect just wouldn't take place.

I am curious though about the minor points you brought up... like why the order of the rules should be reversed.