SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    googlicious graymatter bvarvel's Avatar
    Join Date
    Sep 2002
    Location
    Katy, TX
    Posts
    952
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Redirect If Missing Variable

    I'm using the following Rewrite rule to process variables:

    PHP Code:
     RewriteRule ^properties/([0-9]+)/?$ showprop.php?id=$[L
    Is there anyway to add another command, to redirect if no variable is offered?

  2. #2
    get into it! bigduke's Avatar
    Join Date
    May 2004
    Location
    Australia
    Posts
    847
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i believe yer looking for conditional redirect. there's an article here on sitepoint for this, look around

  3. #3
    SitePoint Zealot krt's Avatar
    Join Date
    Sep 2005
    Location
    Australia
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Conditional is based on a condition bigduke, what he is doing is just matching against a pattern.
    And bvarvel, you need to be a little more specific, are you saying that if there is nothing in \\1, then go to a specified page?
    If so you could use this:
    Code:
    RewriteRule ^properties(/([0-9]+))?/?$ showprop.php?id=$2 [L]
    I just added another parenthesis set and a yes/no quantifier so if there is no number providied in the URL after "properties" then it will just go to showprop.php?id=
    From there, you just add a line in showprop.php that says if(!$_GET['id']) die('No property ID');
    Let me know if you have any questions

  4. #4
    googlicious graymatter bvarvel's Avatar
    Join Date
    Sep 2002
    Location
    Katy, TX
    Posts
    952
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you KRT... that's exactly what I needed!


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
  •