Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    RewriteRule with 2 variables

    This is the code I have in my .htaccess.

    Code:
    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} -s
    RewriteRule ^ - [L]
    RewriteRule ^([^/]+),([^/]+)$ index.php?id=$1&mode=$2 [NC,L]
    The last line is the important one for the problem I am having. It means I can have a url:
    www.domain.com/home,all
    which is the same as:
    www.domain.com/?id=home&mode=all

    It works great when the url has ".com/something,something" even ".com/home,s" or "home,1". The problem occurs when I just have ".com/home" or ".com/home,".

    Does anyone know how I can have it work with either id=$1 alone or with &mode=$2.

    Thanks.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Try
    Code:
    RewriteRule ^([^/]+),?([^/]+)?$ index.php?id=$1&mode=$2 [NC,L]
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •