Forum Moderators: phranque

Message Too Old, No Replies

{QUERY STRING} in URL write

         

JohnsonHk

2:45 pm on Aug 3, 2009 (gmt 0)

10+ Year Member



I found a URL REwrite as follows:
index.php?main=index&c=202

RewriteRule ^(.*)_c([0-9]+)$ index\.php?main=index&c=$2&%{QUERY_STRING} [L]

but I am not sure whether it is right or not, and what is the usage of {QUERY_STRING} in this rule?

g1smd

7:07 pm on Aug 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It re-appends the original query string data.

The (.*) part of the pattern is dangerous in several ways:
- it isn't passed as $1 to your script and therefore its value is not checked or validated: that's a duplicate content issue.
- the usage of (.*) as a pattern is very inefficient, requiring multiple back-off and retry attempts before a match can be found. If the following underscore is the very first underscore in the URL change the pattern to "match 'not an underscore' until the first underscore", like:

([^_]+_)
or similar.

Do not escape the period in the target filepath. Only escape them in patterns.