SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot jooles's Avatar
    Join Date
    Jun 2006
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    GET, POST To Work With modrewrite?

    Hello

    I have a search form on my site that passes a variable to a search.php page that grabs that variable and does a search

    mysite.com/search/search.php?variable=reallycoolcontent

    But I want to keep the URLs clean so it appears like this:

    mysite.com/search/reallycoolcontent

    How can I get the GET and POST variable to work with a clean modrewritten URL?

    Thanks!

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Same as without modrewritten URL, it doesn't change anything when it gets to php.
    Saul

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think hes asking how to get the variable out of the clean URL when its not in the normal GET format? For example:

    http://mydomain.com/users/search/myusername
    http://mydomain.com/users/search?username=myusername

    He wants to get "myusername" out of the top one. Right? Well I forget the exact index name but there is a value in the $_SERVER global variable that will hav the /users/search/myusername string. You just have to explode() it and parse out the variables from the script path.
    Happy switcher to OS X running on a MacBook Pro.

    Zend Certified Engineer

  4. #4
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Using ForceType, yes. But jooles is talking about mod_rewrite, in which case there's no difference.
    Saul

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by php_daemon View Post
    Using ForceType, yes. But jooles is talking about mod_rewrite, in which case there's no difference.
    It still sounds to me like hes trying to get "reallycoolcontent" out of his URL like a variable. Before he would've jsut done $_GET['variable'] but because reallycoolcontent is now PART of the URL, and not actually a get variable, he would have to access the $_SERVER['REQUEST_URI'] value and parse it.
    Happy switcher to OS X running on a MacBook Pro.

    Zend Certified Engineer

  6. #6
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Read into his post, he said he's using mod_rewrite.
    Saul

  7. #7
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by php_daemon View Post
    Read into his post, he said he's using mod_rewrite.
    Right, I guess I'm too used to thinking that the variables will be vary in length so I'm used to parsing it I guess in his case he is just doing

    RewriteRule /search/(.+) /search.php?variable=$1
    Happy switcher to OS X running on a MacBook Pro.

    Zend Certified Engineer

  8. #8
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Most likely yes, at least I think he is.
    Saul


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
  •