#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Location
    Charlotte, NC
    Posts
    11
    Rep Power
    0

    Htaccess and $_GET variables


    I currently have a rewrite rule in my htaccess file that gets a parameter from the url so I can use it as a $_GET variable.

    Code:
    RewriteEngine on
    
    # Hide file extension
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php
    
    # Rules for Signup Page
    RewriteRule ^signup/([a-z]+) signup.php?step=$1
    The rule for the signup page is the one giving me the trouble. I can pass a url like http://www.mysite.com/signup/confirm/ and it works just fine. The problem is when I use the URL without the parameter like http://www.mysite.com/signup/, I get a 500 error.
  2. #2
  3. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,131
    Rep Power
    4304
    Specific rules need to go before more general rules.

    Code:
    RewriteEngine on
    
    # Rules for Signup Page
    RewriteRule ^signup/([a-z]+) signup.php?step=$1
    
    # Hide file extension
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    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