Welcome to WebmasterWorld Guest from 54.224.49.217

Forum Moderators: Ocean10000 & incrediBILL & phranque

How to replace %26 for & on htaccess

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

New User

joined:July 24, 2017
posts: 2
votes: 0


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
12:13 am on July 25, 2017 (gmt 0)

Moderator from US 

WebmasterWorld Administrator keyplyr is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 26, 2001
posts:9631
votes: 479


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.
12:24 am on July 25, 2017 (gmt 0)

New User

joined:July 24, 2017
posts: 2
votes: 0


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 .
2:11 am on July 25, 2017 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:14017
votes: 520


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?