The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 22, 2019, 05:33:38 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Mod_Rewrite - again =(  (Read 1879 times)
DangerMouse
Expert
****
Offline Offline

Posts: 244



View Profile
« on: November 07, 2008, 08:47:04 AM »

Hi all,

Firstly an apology - 90% of my contributions to this forum recently appear to be asking for help rather than being helpful! I'm just really stuck for time at the moment and haven't been able to spend my usual time surfing.

Anyways, to the issue at hand. Given the following .htaccess file ( a typical OSCommerce rewrite job ) any chance someone can give me some tips on how I would go about ensuring a specified URL paramater was maintained? Basically, I think the rules as they stand are stripping the AdWords gclickId, so I'd like to ensure it's preserved but my knowledge of regular expressions and mod_rewrite is pitifully weak so am stuck.

Code:
Options -Indexes

Options +FollowSymLinks

RewriteEngine On
RewriteBase /

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}

Ideas?

DM
Logged
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #1 on: November 07, 2008, 09:29:23 AM »

{QUERY_STRING} should preserve it.

Absent that, a simple addition of another (.*) would do it, and then you would use $3 to reference that third grouping.

E.g.
Code:
RewriteRule ^(.*)-p-(.*).html(.*?)$ product_info.php?products_id=$2&$3
Logged

hai
DangerMouse
Expert
****
Offline Offline

Posts: 244



View Profile
« Reply #2 on: November 07, 2008, 09:47:09 AM »

Will give that a go thanks vsloathe but thinking about it, I feel you're right - I can't see any reason why this would strip a paramater from the URL as to my knowledge no redirects are occuring? Plus when I type an arbitary paramater on to the end of a URL the paramater remains.

I may have jumped the gun with this post, maybe my issue is elsewhere.

Ta,

DM

Logged
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!