Log in

View Full Version : Resolved .htaccess mod rewrite inconsistent on reload



djr33
12-31-2013, 12:24 AM
I can't figure out what's going on, and I'm not sure where to start in trying to fix it.

Here's the setup:

I have a Go Daddy hosting account that has several domains pointed to it.
MAINDOMAIN.com is the "primary domain", which is by default set to the root directory.
The other domains are by default pointed to folders like domain.com to directory 'domain.com/'.

What I want:
MAINDOMAIN.com should NOT access the root; instead, it should access a folder called 'MAINDOMAIN/'.
I don't want any website-specific files in the root, and I don't want the websites to be potentially loaded through another (a.com/b.com/....).

What I've done:
I set up .htaccess with mod_rewrite to solve this. Simple. And it worked for over a year.
Recently* this stopped working. I have no idea why. (*well, not too recently-- a few months ago, and I've been too busy/confused to fix it)

I'm using this .htaccess code:


Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} MAINDOMAIN.com
RewriteCond %{REQUEST_URI} !^/MAINDOMAIN
RewriteRule ^(.*)$ MAINDOMAIN%{REQUEST_URI}


Sometimes when I load a page, it works. Sometimes it doesn't (404). Refreshing (especially shift+refresh-- force reload everything) usually helps. Sometimes when I continuously refresh it just loops back and forth between working and not working. What's going on!??

[EDIT: DEMO PAGES REMOVED]

I have no idea why some pages/files are more likely to have problems than others....


--
Part 2:
I also have another layer of .htaccess in one part of the website (a subdirectory).
This is just all messed up. Some pages are loaded through a single PHP page that generates the template.
It's inconsistent (and sometimes the poster loads, other times it doesn't).

I assume this will be fixed once the other problem is fixed, and this is just another level of not being sure where to start in fixing it. And it's not a huge priority right at the moment. But it's still odd.



Any ideas? Why would .htaccess be inconsistent? It's not wrong, it's just not always right.....?

traq
12-31-2013, 02:28 AM
Don't know. Does GoDaddy not provide some cp functionality that allows you to choose root directories for each of your domains? I've run into confusing stuff before trying to make htaccess do the work of a vhost file.

djr33
12-31-2013, 05:58 PM
I haven't been able to find anything. That would be a simpler solution and I'd be happy with it. I can look around.
In theory, I'd expect .htaccess should work. But as you said, it's confusing! I barely know what I'm doing with .htaccess anyway, so when the basics don't work out, I'm pretty much lost.

djr33
12-31-2013, 08:29 PM
Update: I've solved this indirectly. There must be a primary domain setup with the root directory. So I set an irrelevant (non-existent, in fact) subdomain as the "primary"/root domain and switched my main domain to the desired folder. Now it's working fine. I still have to reconfigure some of the internal .htaccess mod_rewrite stuff, but that's fine. At least that makes sense to begin with. Thanks for motivating me to look for a workaround again.