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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    311
    Thanks
    0
    Thanked 1 Time in 1 Post

    Mod rewrite issue

    I have an issue with a mod_rewrite. The issue is that I have my rewrite setup as follows

    PHP Code:
    RewriteRule ^question/(.*)/(.*)/(.*)/(.*)$ /viewtopic.php?cat_id=$1&f=$2&id=$3&pageno=$
    it works fine but if I use the following URL it does not work and gives me a 404 error

    Here is the URL that does NOT work

    PHP Code:
    question/arts-and-humanities/visual-arts/what-does-opa-mean-in-greek?/ 
    what am I doing wrong?

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Your regular expression expects 4 values, but your URL only has 3. Add another one after that one that deals with 3 and gives the PHP file a default value for the page(1 for example).

  • #3
    Regular Coder
    Join Date
    Aug 2006
    Posts
    311
    Thanks
    0
    Thanked 1 Time in 1 Post
    That didn't fix the issue. The issue is with the question mark. If I pull the question mark from the URL it pulls the page but then gives me a db error because it is looking for the row in the DB that has the question mark. My query needs the question mark but the ? mark is not being allowed in the URL. Any other Ideas?

  • #4
    Regular Coder
    Join Date
    Jun 2004
    Posts
    565
    Thanks
    0
    Thanked 18 Times in 18 Posts
    Encode the path parts with urlencode when you build the URL and urldecode them when you put them in the query.

    dumpfi
    "Failure is not an option. It comes bundled with the software."
    ....../)/)..(\__/).(\(\................../)_/)......
    .....(-.-).(='.'=).(-.-)................(o.O)...../<)
    ....(.).(.)("}_("}(.)(.)...............(.)_(.))Ż/.
    ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
    Little did the bunnies suspect that one of them was a psychotic mass murderer with a 6 ft. axe.

  • #5
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Well, you shouldn't allow the question mark in the URL to begin with because it's supposed to separate the filename from the query string, but if you don't mind the extra chars you can urlencode() the URL, which will replace ? with &#37;3F.


  •  

    Posting Permissions

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