1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Rep Power

    2 .htaccess rules?

    Hi' I'm finally getting the hang of .htaccess

    Now i need 2 rules.. How would I do this?
    This is giving a conflict.. only 1 of the 2 is working but i need them both

    When a person goes to mysite.com/page the first rule needs to be used.. but when a user goes to mysite.com/page/2
    I want the second rule to apply. what's the best way to approach this? thanks!

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?page=$1
    RewriteRule ^(.*)/(.*)$ index.php?page=$1&lijst=$2 [L]
  2. #2
  3. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    USA (verifiably)
    Rep Power
    The most common solution is to change their order, so that the most general rule comes last. However, in this case you could use a character class of all characters except a slash, "([^\/]*)", instead of "(.*)".

    There might even be a third option. You could modify the index.php to check if there is a slash in the value of $_GET['page'] and if so split it.

    FYI, the RewriteCond directives only apply to the first RewriteRule that follows them.
    Spreading knowledge, one newbie at a time.

    Learn CSS. | PHP includes | HTML Validator | CSS validator

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).

IMN logo majestic logo threadwatch logo seochat tools logo