Page 1 of 1

Short URLs with &search on the end - not working

Posted: Fri Nov 27, 2015 8:17 am
by simonmlewis
I have a neat little video page for a client, as they have hundreds on their web site, attached to products. Customers like searching for them.

So now they can scan thru the categories, but also search for a product and up comes all the results.
The first result in date order (newest first) shows as a video at the top, with the rest of them below it, as tiled DIVs.

When they search and the results come up, the url is a full url.
But when they click the product to view from the result, it changes to:
/videos/product/55/160/&search=shirt&searchvideo=y
The "searchvideo=y" is what commands the results below to look for results of the search, rather than results of the catid (55).

But if they click that link, the cat id is used (as it highlights that products category on the left menu), and the product's video plays, but none of the following variables are picked up.

So the search it then belows for the products, is based on the Catid, not the search variable.

I'm using this in this order in HTACCESS:

Code: Select all

RewriteRule ^videos/product/([0-9]+)/([0-9]+) /index.php?page=videos&catid=$1&id=$2 [QSA]
RewriteRule ^videos/([0-9]+) /index.php?page=videos&catid=$1 [QSA]
Have tried it the other way around too.
Also tried [L].

Nothing seems to work.

Re: Short URLs with &search on the end - not working

Posted: Fri Nov 27, 2015 8:46 am
by simonmlewis
Might have cracked it. Not found the reason for it, but adding a new rule for videos/product-search.... that seems to work, and will mean better for people to share the URL without the & signs.

Re: Short URLs with &search on the end - not working

Posted: Fri Nov 27, 2015 7:17 pm
by requinix
I'm not too sure what's going on, and you say you have it fixed already, but

With those two RewriteRules the URL you posted will be rewritten to

Code: Select all

/index.php?page=videos&catid=55&id=160
The search=shirt and searchvideo=y aren't passed along because it's missing a ?. As in

Code: Select all

currently: /videos/product/55/160/&search=shirt&searchvideo=y
should be: /videos/product/55/160/?search=shirt&searchvideo=y
which is probably a problem with the URLs generated by the search page. If you fixed that then the rewritten URL would be

Code: Select all

/index.php?page=videos&catid=55&id=160&search=shirt&searchvideo=y
ie, the two extra query string parameters from before will be carried over.