SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Get variable from Rewrite url?

    I have an url looking like this:
    mysite.com/ciccms/myname/mypage

    Which is done with urlrewrite in .htaccess file.
    RewriteRule ^ciccms/([A-Za-z0-9_]+)/?([A-Za-z0-9_]*)/?$ ciccms/index.php?name=$1&page=$2 [L]

    Now I add a variable like this to the url
    mysite.com/ciccms/myname/mypage?test=15

    Now I want to retrieve the variable "test" like this but nothing happens?
    PHP Code:
    $testurlencode($_GET['test']);
    echo 
    $test
    What am I doing wrong?

    Thanks in advance :-)

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,506
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Try
    Code:
    RewriteRule ^ciccms/([A-Za-z0-9_]+)/?([A-Za-z0-9_]*)/?$ ciccms/index.php?name=$1&page=$2 [L,QSA]
    The [QSA] in the RewriteRule should make sure that the original query string will be appended to the rewritten URL.

  3. #3
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by guido2004 View Post
    Try
    Code:
    RewriteRule ^ciccms/([A-Za-z0-9_]+)/?([A-Za-z0-9_]*)/?$ ciccms/index.php?name=$1&page=$2 [L,QSA]
    The [QSA] in the RewriteRule should make sure that the original query string will be appended to the rewritten URL.
    Thanks... Worked like a charm ;-)


Bookmarks

Posting Permissions

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