EYEHEARTZOMBIES

The Lowdown mod_rewrite Blues, part 2

April 30

Of course, I should have posted what my mod_rewrite situation looks like. Well, here it is: index.php processes a variable and outputs the appropriate page (to avoid hack attempts, it adds .php to the end of the input) inside the template. mod_rewrite’s job, then, is to assign the appropriate page to index.php.

My current mod_rewrite statement (which works, sort of) is:
RewriteEngine on
RewriteRule ^page/(.*)$ index.php?variable=$1 [L]

This requires me to give a URL like http://www.gigantuan.net/page/front/. I want http://www.gigantuan.net/article/css/css_is_good/. I think I could get this with no problems by setting up a rule for articles, a rule for comments, and so on and so forth…but I need a default as well, or else I’m stuck with /page/front. Also, I can’t do any global redirects because I have other sites on the server and it messes them up royally.

  • 1

    Why do you redirect to /page at all when you try and load the http://www.gigantuan.net?

    Couldn’t you do something like:

    RewriteRule ^(.*)/$ index.php?section=$1[L]

    RewriteRule ^(.*)/(.*)/$ index.php?section=$1&category=$2&article=$3 [L]

    RewriteRule ^(.*)/(.*)/(.*)/$ index.php?section=$1&category=$2&article=$3 [L]

    I might be totally misunderstanding what you are trying to do.

    ramanan on April 30, 2004 at 12:15 pm

Leave a comment