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 3 of 3
  1. #1
    Regular Coder DR.Wong's Avatar
    Join Date
    Jan 2005
    Posts
    360
    Thanks
    23
    Thanked 1 Time in 1 Post

    Using "/" instead of "?" for php values in URL

    Hey everyone!

    You all know the $_GET statement, getting the values after "?var=1&type=2"...

    Is there a way of saying "http://www.mysite.com/1/2" and getting PHP to read the variables from this, at the same time keeping the browser in the root directory?

    I reckon this would help google index my site as well.

    Thanks a lot!!
    -DR.Wong

    Wheres the food at?

  • #2
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Are you wanting to know how to have your URL rewritten from your 1st example to look like in your 2nd example?

    If you're server is Apache. I think you should look into Mod Rewrite . www.modrewrite.com
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #3
    New to the CF scene
    Join Date
    Nov 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I do this quite frequently. I think I borrowed the same approach drupal uses, which is to grab everything, call it some variable, and rewrite to a script that parses the url.
    Code:
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_URI} (\.php$|\/$)
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    Then index.php splits up $q and knows what to do. This gives you lots of control.


  •  

    Posting Permissions

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