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

    Join Date
    Sep 2012
    Posts
    204
    Rep Power
    2

    Litle .htaccess help


    Hi! i have website which takes 2 $_GET requests.. as following

    localhost/?pack=5&date=880925

    I would like to use these as

    localhost/5/880925

    I tried different solutions. but none seem to work.. only removing the file extension worked.

    thank you!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,985
    Rep Power
    375
    so what did you try in htaccess.. post your code and we can correct it for you
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    204
    Rep Power
    2
    Thanks for the fast reply, this is the code i'm trying to use

    Code:
    <IfModule mod_rewrite.c>
    Options +FollowSymlinks
    
    RewriteEngine on
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^date/pack/(.*)(/?)$ index.php?date=$1&pack=$2 [L]
    
    </IfModule>
  6. #4
  7. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    localhost/5/880925
    Code:
    RewriteRule ^date/pack/(.*)(/?)$ index.php?date=$1&pack=$2 [L]
    Those don't really line up but it's not too far off; your RewriteRule says you want the URL to look like:
    localhost/date/pack/5

    You have that extra text at the beginning, and you only have one matching group instead of 2.

    Additionally, . will match everything including forward slashes, so .* isn't a good condition to use inside your groups. Instead using something like ([^/]+)
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo