| Su | Mo | Tu | We | Th | Fr | Sa |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 |
Browse archives
Search |
Programming voodoo - apache RewriteRule(s)I always liked this quote from Brian Moore: Despite the tons of examples and docs, mod_rewrite is voodoo. Damned cool voodoo, but still voodoo. I wonder if he is known for anything other than this quote? I have had the pleasure of stumbling around rewrite rules several times, and once again read through about 30 examples that were all more complicated than I needed. I am at the stage in learning this where it seems easy enough but didn't work as expected. All that I wanted to do was to redirect the home page url / to a subdirectory /store/. No wild cards needed, nothing fancy, just direct a single url to another place. The problem was with the way that a redirect may interact with other apache directives in other files. I was doing this in the root directory .htaccess file and had looked at the httpd.conf file before but not lately. Apparently, the default page choices will override a redirect, so what seems obvious: RewriteRule ^/$ /store/index.php does not work by itself. An hour later, I figured out that this is apparently unneeded and ended up with: RewriteEngine on The key is the last rule (come to think of it, the others are probably not necessary). Since the conf file already has a default page choice of index.html, all that is needed is to redirect this page to the store page. For those newbees who haven't got as far as understanding the syntax, the carat is used to start the rule and the dollar sign is the terminator for the match pattern. It becomes clear why these are needed when you start using pattern matching to write rules. Generally, I would have to give my compliments to the Apache folks for doing a decent job with the docs (and of course the software as well). By Roger Campbell at Sep 7 2005 - 9:48am
|
NavigationUser loginSyndicate |