Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help needed with URL rewrite

2 views
Skip to first unread message

zeebop

unread,
May 21, 2009, 12:58:54 PM5/21/09
to
Hi,

At the moment, if a variable is added to the end of a URL the page is
loaded but the variable removed from the URL.

I need (for Adword tracking purposes) for whatever variable set, to
remain.

I am assuming this is to do with the rules set in the .htaccess file?
All pages are called from within /catalog/ the .htaccess from that
directory is below:

=====
Options +FollowSymLinks
RewriteEngine On
RewriteBase /catalog/

RewriteRule ^(.*)-p-(.*).html$
product_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-m-(.*).html$
index.php?manufacturers_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pi-(.*).html$ popup_image.php?pID=$2&%{QUERY_STRING}
RewriteRule ^(.*)-t-(.*).html$ articles.php?tPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-a-(.*).html$
article_info.php?articles_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pr-(.*).html$
product_reviews.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pri-(.*).html$
product_reviews_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-i-(.*).html$
information.php?info_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-links-(.*).html$ links.php?lPath=$2&%{QUERY_STRING}
=====

Can anyone suggest how to make the random variable remain?

HansH

unread,
May 21, 2009, 6:43:42 PM5/21/09
to
"zeebop" <ye...@um.right> schreef in bericht
news:l02b159tv12sda9bg...@4ax.com...

> At the moment, if a variable is added to the end of a URL the page is
> loaded but the variable removed from the URL.
>
> I need (for Adword tracking purposes) for whatever variable set, to
> remain.
>
> =====
> Options +FollowSymLinks
> RewriteEngine On
> RewriteBase /catalog/
>
> RewriteRule ^(.*)-p-(.*).html$
> product_info.php?products_id=$2&%{QUERY_STRING}
> RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING}
> RewriteRule ^(.*)-m-(.*).html$
> index.php?manufacturers_id=$2&%{QUERY_STRING}
> RewriteRule ^(.*)-pi-(.*).html$ popup_image.php?pID=$2&%{QUERY_STRING}
> RewriteRule ^(.*)-t-(.*).html$ articles.php?tPath=$2&%{QUERY_STRING}
> RewriteRule ^(.*)-a-(.*).html$
> article_info.php?articles_id=$2&%{QUERY_STRING}
> RewriteRule ^(.*)-pr-(.*).html$
> product_reviews.php?products_id=$2&%{QUERY_STRING}
> RewriteRule ^(.*)-pri-(.*).html$
> product_reviews_info.php?products_id=$2&%{QUERY_STRING}
> RewriteRule ^(.*)-i-(.*).html$
> information.php?info_id=$2&%{QUERY_STRING}
> RewriteRule ^(.*)-links-(.*).html$ links.php?lPath=$2&%{QUERY_STRING}
> =====
Replace &%{QUERY_STRING} with [QSA,L]
QSA will Appand the QueryString to the rewritten request
and L will make current rule the Last one executed if matching
Order the rules from most likely down to least likely to avoid wasting CPU
time.

You should consider putting RewriteRule !\.html$ - [L]
on top to avoid wasting CPU time on not rewriteable requests.

> Can anyone suggest how to make the random variable remain?

Does that happens to be the part of the match before -*-?
Try (on one line)
RewriteRule ^(.*)-p-(.*).html$
product_info.php?products_id=$2&Ad=$1 [L,QSA]

Otherwise, do provide a sample.

HansH

zeebop

unread,
May 22, 2009, 10:24:40 AM5/22/09
to
On Fri, 22 May 2009 00:43:42 +0200, "HansH" <ha...@invalid.invalid>
wrote:

Thank-you for your response, you can see the rewrite in effect at:
www.condomchoice.co.uk - please do let me know if you think the above
will work.

Luuk

unread,
May 22, 2009, 1:35:39 PM5/22/09
to
zeebop schreef:

no, it does not work:
http://www.condomchoice.co.uk/catalog/x-p-2.html

gives error:
Warning: Cannot modify header information - headers already sent by
(output started at
/home/condomch/public_html/catalog/product_info.php:21) in
/home/condomch/public_html/catalog/includes/classes/seo.class.php on
line 1057

Warning: Cannot modify header information - headers already sent by
(output started at
/home/condomch/public_html/catalog/product_info.php:21) in
/home/condomch/public_html/catalog/includes/classes/seo.class.php on
line 1058

Product not found!


--
Luuk

HansH

unread,
May 22, 2009, 7:51:22 PM5/22/09
to
"Luuk" <lu...@invalid.lan> schreef in bericht
news:2c4je6-...@qqqqq.xs4all.nl...

>> Thank-you for your response, you can see the rewrite in effect at:
>> www.condomchoice.co.uk - please do let me know if you think the above
>> will work.
>
> no, it does not work:
> http://www.condomchoice.co.uk/catalog/x-p-2.html
>
> gives error:
> Warning: Cannot modify header information - headers already sent by
> (output started at /home/condomch/public_html/catalog/product_info.php:21)
> in /home/condomch/public_html/catalog/includes/classes/seo.class.php on
> line 1057
>

It is hard to blame a rewrite for a crash on a randomly choosen
product id used in a crafted -that is not provided- URL.
OP need to attend ot this issue seperately.

HansH


HansH

unread,
May 22, 2009, 8:13:12 PM5/22/09
to
"zeebop" <ye...@um.right> schreef in bericht
news:mbdd159vv5knqif4i...@4ax.com...

>>> At the moment, if a variable is added to the end of a URL the page is
>>> loaded but the variable removed from the URL.
>>>
>>> I need (for Adword tracking purposes) for whatever variable set, to
>>> remain.

>>> Can anyone suggest how to make the random variable remain?


>>Does that happens to be the part of the match before -*-?
>>Try (on one line)
>> RewriteRule ^(.*)-p-(.*).html$
>> product_info.php?products_id=$2&Ad=$1 [L,QSA]
>>
>>Otherwise, do provide a sample.
>>

> Thank-you for your response, you can see the rewrite in effect at:
> www.condomchoice.co.uk - please do let me know if you think the
> above will work.

Obviously adding &Ad=$1will not do. The site shows the phrase before
the discriminator is a human readable reference to the product.

Do provide a sample of working URL showing where and what is
inserted or appended by Google. Most likely you can find good
samples in your site's accesslog.

HansH


zeebop

unread,
May 23, 2009, 8:24:30 AM5/23/09
to
On Sat, 23 May 2009 02:13:12 +0200, "HansH" <ha...@invalid.invalid>
wrote:

Here is an example:
http://www.google.com/support/googleanalytics/bin/answer.py?hl=en-uk&answer=55590

Basically it appends gclid:
www.mysite.co.uk/?gclid=123xyz

HansH

unread,
May 23, 2009, 4:55:18 PM5/23/09
to
"zeebop" <ye...@um.right> schreef in bericht
news:smqf151m24qt4nb2f...@4ax.com...

> On Sat, 23 May 2009 02:13:12 +0200, "HansH" <ha...@invalid.invalid>
> wrote:
>>Do provide a sample of working URL showing where and what is
>>inserted or appended by Google. Most likely you can find good
>>samples in your site's accesslog.
>>

That has the looks of just an extra query string element and should be
passed by
RewriteRule ^(.*)-p-(.*).html$
product_info.php?products_id=$2 [L,QSA]

A request for
/catalog/x-p-2.html?gclid=123xyz
should be rewritten into
/catalog/product_info.php?products_id=2&gclid=123xyz

Unfortunately you dit not provide a live sample, thus the above still is
theory...

Check Apache's access_log for any lines having a 'gclid=' phrase

HansH


0 new messages