.htaccess - Help needed. Please help! Should be simple...

Discussion in 'Programming' started by monkeyclap, Apr 25, 2013.

  1. #1
    monkeyclap, Apr 25, 2013 IP
  2. dorco

    dorco Greenhorn

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #2
    i m not sure if it works but try this:
    RewriteRule ^([a-z0-9\-\.]+)/([a-z0-9\-]+) $1?q=$2
     
    dorco, Apr 25, 2013 IP
  3. monkeyclap

    monkeyclap Active Member

    Messages:
    836
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    85
    #3
    It's messing up my site's layout. I also have other stuff in .htaccess - not sure if that's why?
     
    monkeyclap, Apr 25, 2013 IP
  4. nhl4000

    nhl4000 Well-Known Member

    Messages:
    479
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    110
    #4
    Have you tried (added .php):
    RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ $1.php?q=$2
    Code (markup):
     
    nhl4000, Apr 25, 2013 IP
  5. monkeyclap

    monkeyclap Active Member

    Messages:
    836
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    85
    #5
    Ah yes, that was it. Thanks guys! :D
     
    monkeyclap, Apr 25, 2013 IP
  6. monkeyclap

    monkeyclap Active Member

    Messages:
    836
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    85
    #6
    Ah, I have noticed a slight bug though. In cases where $2 contains an underscore, it no longer works. Any ideas?
     
    monkeyclap, Apr 25, 2013 IP
  7. nhl4000

    nhl4000 Well-Known Member

    Messages:
    479
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    110
    #7
    Add _ to the parameters.
    RewriteRule ^([A-Za-z0-9-_]+)/([A-Za-z0-9-_]+)/?$ $1.php?q=$2
    Code (markup):
    Similarly,
    To allow any characters:
    RewriteRule ^(.*)/(.*)/?$ $1.php?q=$2
    Code (markup):
     
    nhl4000, Apr 25, 2013 IP
  8. monkeyclap

    monkeyclap Active Member

    Messages:
    836
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    85
    #8
    Perfect! Thanks so much!
     
    monkeyclap, Apr 25, 2013 IP