Forum Moderators: phranque

Message Too Old, No Replies

How to replace %26 for & on htaccess

         

kelsjc

11:36 pm on Jul 24, 2017 (gmt 0)

5+ Year Member



I need to substitute the character %26 for & and %3D for = in my URL:

http://www.example.com/dir/?sort-by=title%26listing_types%3Dcars

I tried the rewrite below but it does not work

RewriteRule ^dir/?$ ?sort-by=$1&listing-types=$2 [QSA,L]


Any help will be welcome

keyplyr

12:13 am on Jul 25, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi kelsjc and welcome to WebmasterWorld [webmasterworld.com]

Those are just spaces in the parameter. Are you sure the links won't work without them? I remove spaces all the time in link paths.

kelsjc

12:24 am on Jul 25, 2017 (gmt 0)

5+ Year Member



Actually i need to retrieve the parameters e.g. $GET['listing-types']

So I need the & and =

Is there any other workaround other than htaccess?
I tried using urldecode but it does not work .

lucy24

2:11 am on Jul 25, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I tried the rewrite below but it does not work

RewriteRule ^dir/?$ ?sort-by=$1&listing-types=$2 [QSA,L]

This doesn't make sense. What do the $1 and $2 refer back to?

Incidentally, there really needs to be a leading / in the target for security. And in an internal rewrite there should never be a ? in the pattern, since you're just setting yourself up for duplicate content.

Is this hand-rolled PHP or is there a CMS involved?