...

View Full Version : Mod rewrite issue



Jacobb123
01-05-2008, 10:47 AM
I have an issue with a mod_rewrite. The issue is that I have my rewrite setup as follows


RewriteRule ^question/(.*)/(.*)/(.*)/(.*)$ /viewtopic.php?cat_id=$1&f=$2&id=$3&pageno=$4 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


question/arts-and-humanities/visual-arts/what-does-opa-mean-in-greek?/

what am I doing wrong?

Inigoesdr
01-05-2008, 12:58 PM
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).

Jacobb123
01-05-2008, 06:13 PM
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?

dumpfi
01-05-2008, 07:25 PM
Encode the path parts with urlencode (http://www.php.net/manual/en/function.urlencode.php) when you build the URL and urldecode (http://www.php.net/manual/en/function.urldecode.php) them when you put them in the query.

dumpfi

Inigoesdr
01-05-2008, 07:25 PM
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() (http://php.net/urlencode) the URL, which will replace ? with %3F.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum