Forum Moderators: phranque
I need to rewrite a incoming url from
http://www.example.com/store/product_info.php?ad=bizrate?products_id=33
to
http://www.example.com/store/product_info.php?ad=bizrate&products_id=33
only change is the? to a & behind ad=bizrate
its causing products not to show and could use a solution quickly if possible.
let me know
thanks
David
[edited by: jdMorgan at 10:18 pm (utc) on Nov. 23, 2004]
[edit reason] Obscured specifics per TOS [/edit]
Do you already have existing mod_rewrite code? If not, you'll need to add a few setup directives and make sure your server overrides and Options are set correctly.
Here's a point solution, devoid of any of the usual mod_rewrite setup stuff. If you need more, please see the references cited on our charter [webmasterworld.com] and please have a try at solving this yourself.
RewriteCond %{QUERY_STRING} ^ad=bizrate\?products_id=33
RewriteRule ^store/product_info\.php http://www.example.com/store/product_info.php?ad=bizrate&products_id=33 [R=301,L]
to really be product_info.php?ad=bizrate&
where bizrate is would also be ad=froogle ad=yahoo
etc.
The problem is a "?" being sent after bizrate in the top example should really be a &
so this causes the normal url structure to fail.
I do have a current rewrite system in place as well.
i have tried many ways of doing it, but they all fail, time is short considering these are PPC links pointing.
please help if you can..
RewriteRule (.*)?(.*) $1anyreservedword$2 [NE]
RewriteRule (.*)?(.*) $1&$2 [NE]
RewriteRule (.*)anyreservedword(.*) $1?$2 [NE]
Basically you can do it by 3 pattern maches.
1st change the first?
2nd change the remaining? to &
then chang back the first.
the anyreservedword should be a pattern that would not otherwise appear.
Hope it works.
The following approach demonstrates the use of RewriteCond to overcome this limitation.
Rewrite product_info.php?ad=bizrate?<anything> --> product_info.php?ad=bizrate&<anything> :
RewriteCond %{QUERY_STRING} ^ad=bizrate\?(.*)$
RewriteRule ^product_info\.php$ http://www.example.com/store/product_info.php?ad=bizrate&%1 [R=301,L]
Jim
here is the htaccess file.
AddType application/x-shockwave-flash swf
RewriteEngine on
Options +FollowSymlinks
DirectoryIndex home.html home.php index.php index.html
AddType application/x-httpd-php php php4 php3 html htm
RewriteRule ^sitemap_categories.html$ sitemap_categories.php [L]
RewriteRule ^sitemap_products.html$ sitemap_products.php [L]
RewriteRule ^category_([1-9][0-9]*)_([1-9][0-9]*)_([1-9][0-9]*)_([1-9][0-9]*)_([1-9][0-9]*)_([1-9][0-9]*)\.htm$
RewriteRule ^category_([1-9][0-9]*)_([1-9][0-9]*)_([1-9][0-9]*)_([1-9][0-9]*)_([1-9][0-9]*)\.html$ index.php?c$
RewriteRule ^category_([1-9][0-9]*)_([1-9][0-9]*)_([1-9][0-9]*)_([1-9][0-9]*)\.html$ index.php?cPath=$1_$2_$3_$
RewriteRule ^category_([1-9][0-9]*)_([1-9][0-9]*)_([1-9][0-9]*)\.html$ index.php?cPath=$1_$2_$3 [L]
RewriteRule ^category_([1-9][0-9]*)_([1-9][0-9]*)\.html$ index.php?cPath=$1_$2 [L]
RewriteRule ^category_([1-9][0-9]*)\.html$ index.php?cPath=$1 [L]
RewriteRule ^product_([1-9][0-9]*)\.html$ product_info.php?&products_id=$1 [L]
RewriteRule (.*)?(.*) $1ad=bizrate$2 [NE]
RewriteRule (.*)?(.*) $1&$2 [NE]
RewriteRule (.*)ad=bizrate(.*) $1?$2 [NE]
I would thing this would work,
but I tried
/store/product_info.php?ad=bizrate?products_id=84
and it did not work,
but when i go to
/store/product_info.php?ad=bizrate&products_id=84
it still works, (which is good) but for some reason that didnt work.
this has me scratching my head.
btw where 84 is, that changes to thousands of numbers, im wondering if it needs to be set to handle the products_id= part then allow for any number after that to be handled as normal
:P
and
RewriteCond %{QUERY_STRING} ^ad=([^?]+)\?(.*)$
RewriteRule ^store/product_info\.php$ [example.com...] [R=301,L]
no go for both, tried in both locations as well, in root, and in the /store/ directory.
now I'm glad you took our 'emergency' seriously, please understand it really is a true emergency, the links pointing to the site are not indexed search engine urls, these are submited Pay per click links which have already cost over $50, if that does not classify as one i dunno what does heh.
as for the solution, its still being proccessed by oscommerce incorrectly, its not picking up the change.
as for the problem, you understand fully what i need from the code above, but it simply don't work for me.
I think the best thing to do at this point is to disable the links.
somehow.
thanks.
david.
Jim