Forum Moderators: phranque

Message Too Old, No Replies

Rewriting URLs

Shouldn't be that difficult :(

         

mantic

3:59 pm on Apr 30, 2005 (gmt 0)



I'm trying to achieve the following:
foo.com/t1/t2/t3=a&foo=b...

"changed" to foo.com/?var1=t1&var2=t2&q=t3=a&foo=b...

My rule:
^([^/]*)(/([^/]*)(/(.*))?)?

or this version:
^([^/]*)(/([^/]*))?(/(.*))?

works fine, if I remove the last 2 sets of brackets, but then t3=a&foo=b... isnt working.. (of course, because I removed them)

With the last 2 sets of brackets, the server seems too loop, and I really dont understand why :(

My .htaccess file looks like this:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^([^/]*)(/([^/]*)(/(.*))?)? /index.php?area=$1&page=$3&q=$5

sitz

5:09 pm on Apr 30, 2005 (gmt 0)

10+ Year Member



foo.com/t1/t2/t3=a&foo=b

Assuming that's a query string there, it's invalid syntax; a query string requires a '?', so something like:


foo.com/t1/t2/?t3=a&foo=b

Would be a valid HTTP request. Note also that you can't capture query strings with a RewriteRule; you'll need to use RewriteCond. More information on this is available in the forum archives, which are indexed by and searchable via Google [google.com].