Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule

& regular expression

         

o11w

11:10 am on Sep 30, 2005 (gmt 0)

10+ Year Member



Hi,

I'm trying to define a rule but the expression doesn't match.

This is my rule:
RewriteRule ^/base/portfolio/([^/]*)/([^\?]*)\?(.*) /test.php?file=$2&portfolioId=$1$3

I want to convert url like this:
/base/portfolio/[id]/[myscript.php]?[param]
to this:
/base/portfolio/[myscript.php]?portfolio=[id]&[param]

The problem is that the params are not matched and used.
Could you help me?

Thank 10000 times.

Olivier.

o11w

12:59 pm on Sep 30, 2005 (gmt 0)

10+ Year Member



Re-Hi,

I found the solution:

RewriteRule ^/base/portfolio/([^/]*)/([^\]*) /test.php?file=$2&portfolioId=$1 [QSA,L]

[QSA] will add the query string at the end of the address.

cheers mates...

jdMorgan

2:08 pm on Sep 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



o11w,

Welcome to WebmasterWorld!

Glad you found a solution!

SHould you need to test for a query string value in the originally-requested URL, you can use a RewriteCond:


RewriteCond %{QUERY_STRING} ^your-specific-value$

Regular expressions can be used, and you can create back-references as in RewriteRule. The back-reference values can then be de-referenced in the following RewriteRule using %1 through %9.

Jim

o11w

2:29 pm on Sep 30, 2005 (gmt 0)

10+ Year Member



Thanks for the info!
These are my first steps into the apache configuration. It seems so powerful. It give me a lot of ideas to improve my web applications.

Thanks.

Olivier.