Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule doesn't alwasy work

sorry, hard to explain. please have a look...

         

leifwessman

10:33 am on Apr 19, 2004 (gmt 0)

10+ Year Member




Hi!

I have the following RewriteRule:

RewriteRule ^cat/(.*)$ cat.php?q=$1

But when accessing the following cat:

[domain.com...]

$_GET['q'] in cat.php becomes "Internet" and not "Internet & IT" as expected.

Why is that? And how can I avoid it?

Leif

jcoronella

12:20 am on Apr 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Looks strange, although I'm not the best with regexps. Have you made sure that the entire url is being requested?

jdMorgan

2:52 am on Apr 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The regex pattern (.*) is going to include the entire string as variable $1, spaces, ampersands, and all. I suspect the PHP query parser is unencoding it and breaking it up for you as a service -- Which in this case, you don't want.

You might try asking about this subject over in the PHP forum.

Jim

lemat

12:11 pm on Apr 20, 2004 (gmt 0)

10+ Year Member



the URL passed to cat.php will look like

cat.php?q=Internet & IT

and PHP will treat "IT" as a next variable $_GET['IT']
you need to look into $QUERY_STRING (with registerglobals=off check phpinfo() for proper table[key])