Need help with .htaccess redirection

Hello,

I have trouble with some links like next one:

http://localhost/browse?price=DESC&from=87/15/0/

Can you help me how can I redirect those kind of links to page like: http://localhost/items/

With “those kind of links”, I mean links like:
http://localhost/browse/?price=DESC&from=87/15/0/
http://localhost/browse?price=ASC&from=87/15/
http://localhost/browse?price=ASC&from=87/
etc.

Not sure, but looks like the problem is in question mark in url… I tried with

Redirect 301 ^browse(.) /items/
Redirect 301 ^browse(.
)(.*) /items
… but no luck.

Can you help me how can I make redirection to /items/ page please?

Thank you in advance!

coper,

The ? is a reserved character which separates a URI from a query string. This makes handling with mod_alias almost impossible and mod_rewrite requires the use of RewriteCond statements to look into variables other than {REQUEST_URI}.

Warning: Beware the inappropriate use of (.*) as that’s the greatest potential for generating loops (albeit it can’t do that - or anything else) in a Redirect statement.

To redirect from browse to items, Redirect 301 browse /items/ should do (and lose all the information contained in the query strings).

Regards,

DK

you can add this to you .htaccess :

# Redirect old file path to new file path
Redirect http://localhost/items/ http://localhost/browse/?price=DESC&from=87/15/0/

@dklynn,

I need to redirect anything from http://localhost/browse?price=whatever_is_here to http://localhost/items/.

Problem is that redirection of only http://localhost/browse is not enough for me in this case.

I don’t know why did not make it with mentioned redirectives, and that’s why I need help here.

@bagitahu, thank you, but I need redirection for another way round, not like you mentioned.

Pls help
:frowning:

coper,

Did you bother to read the sticky threads or the tutorial article linked in my signature (there are a large number of sample codes in it, too)? If you can’t find the answer at your fingertips, make an attempt and I’ll correct it with you (the reason for my “no coding for script kiddies” rule is to help all members to learn).

Regards,

DK

Tnx, I manage to do it. I created new directory called browse, with single index.html file in it, that contains redirection to the /items link (on server, html file is treated as php).

It is not .heaccess solution, but it’s quick and it works.

Tnx!