lucy24 - 4:06 am on Apr 20, 2013 (gmt 0)
half the problems I have is I don't clear the browser cache
Tip: If you have a test site or a pseudo-server (MAMP or equivalent), slip in this package:
ExpiresByType text/html "access"
ExpiresByType text/php "access"
It means that if you have an obedient browser-- and an obedient ISP --you don't have to keep on refreshing pages and emptying the cache, because each access will result in a fresh request to the server. Obviously you can't do it on the real site that humans visit. At most, you could designate some hidden backwater of your real site as "testing only".
Apache says (here quoting from mod_rewrite docs, but mod_alias docs say essentially the same thing):
Use of the [R] flag causes a HTTP redirect to be issued to the browser. If a fully-qualified URL is specified (that is, including http://servername/) then a redirect will be issued to that location. Otherwise, the current protocol, servername, and port number will be used to generate the URL sent with the redirect.
If the original request happened to use the exactly correct protocol and hostname, then it makes no difference whether the target of a redirect-- whether via mod_alias or mod_rewrite --begins in / alone or the full protocol-plus-host. But it would obviously be senseless to prefix each RewriteRule with a RewriteCond checking whether the HTTP_HOST is already correct, and running different rules depending on whether it is or isn't. Feed in the correct form each time, and everything will come out correct.
mod_alias vs. mod_rewrite
THIS IS IMPORTANT.
The Apache documentation is primarily written for the people who own the server. When it is your own server, you know which mods load in which order, and which rules execute when. On shared hosting, you may or may not know, and it is definitely out of your power to change it.
The one thing you can be sure of is that external redirects must come before internal rewrites. In mod_rewrite, you can attach a RewriteCond to every single rule to look at THE_REQUEST. In mod_alias, there are no conditions; it's like a string of conditionless RewriteRules.