I'm looking for a set of simple rules and redirects for my site. I've tried so many combinations that I'm starting to get confused.
I'm not sure how to set this up. Generally, without mod-rewrite, I would use relative paths to link to files:
if it's in the same directory.
Now I'd like to use this:
And so if you go to this page:
it will take you to the correct place, which would be:
But also, many directory levels deep I would like it to work as well:
would go to:
would go to:
But then in all these cases, if someone were to type in this:
in the URL bar, it would show this:
I think part of the problem I was having was that I had these directories in my site root:
and I also had these files in a directory called
.htaccess file wasn't working until I changed these file names to something else, that was not the same as the directory names. Does this make sense? Is this expected behavior?
I'm sure someone will come to this post looking for similar help as I did when I wrote this question. There are many good answers on mod_rewrite both here and on stackoverflow.com. I recommend reading through those and trying out these conditions and rules on a test instance to get the hang of them.
I realized also that using frequent browser cache clears and activating the RewriteLog is essential to figuring this stuff out. For example:
RewriteLog "rewrite.log" RewriteLogLevel 7