Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Facing issues with special characters in url in dispatcher

Avatar

Avatar
Boost 1
Level 1
p0990m
Level 1

Like

1 like

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
p0990m
Level 1

Like

1 like

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
p0990m
Level 1

25-01-2021

Hi All, We are sending some data through the query parameter in url which has some special characters like { },[], ". Example url : /content/abc/test.html?data={"title":"Get%20a%20Quote%20-%20Compare%20Plans%20and%20Prices","travelers":[{"age":20,"sameAddress":true,"tripCost":300}]}. converted url - /content/abc/test.html?data=%7b%2522title%2522:%2522Get%2520a%2520Quote%2520-%2520Compare%2520Plans%2520and%2520Prices%2522.... In our QA publish url it is working fine, but in the dispatcher url these special characters  are getting converted into their hex-code equivalent. So can you please do let me know what rewrite rules and which file we do need to write in dispatcher to avoid those special characters to getting converted to their hex-code?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 5
Level 3
kiranparab
Level 3

Likes

23 likes

Total Posts

26 posts

Correct Reply

11 solutions
Top badges earned
Boost 5
Boost 3
Boost 10
Boost 1
Affirm 5
View profile

Avatar
Boost 5
Level 3
kiranparab
Level 3

Likes

23 likes

Total Posts

26 posts

Correct Reply

11 solutions
Top badges earned
Boost 5
Boost 3
Boost 10
Boost 1
Affirm 5
View profile
kiranparab
Level 3

27-01-2021

Hi,

 

Avoid encoding dispatcher URLs -

 
Rewrite rules on Apache web server that attempt to redirect to URLs with special characters such as & or ? or #anchor aren't being redirected properly.  For example:
RewriteRule ^/we-retail.html /we-retail.html#anchor [R=301,L]
 
To avoid encoding the # character, add the NE flag to the rewrite rules:
 
RewriteRule ^/test.html /test.html#anchor [NE,R=301,L]
 
Special characters such as & and ?, will be converted to their hexcode equivalent. Using the [NE] flag prevents that from happening.
RewriteRule ^/anchor/(.+) /bigpage.html#$1 [NE,R]
 
The above example will redirect /anchor/xyz to /bigpage.html#xyz. Omitting the [NE] will result in the # being converted to its hexcode equivalent, %23, which will then result in a 404 Not Found error condition.
 
 
Thanks,
Kiran Parab

Answers (3)

Answers (3)

Avatar

Avatar
Boost 5
Level 2
lucian_nicolaescu
Level 2

Likes

8 likes

Total Posts

7 posts

Correct Reply

3 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 3
Affirm 1
View profile

Avatar
Boost 5
Level 2
lucian_nicolaescu
Level 2

Likes

8 likes

Total Posts

7 posts

Correct Reply

3 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 3
Affirm 1
View profile
lucian_nicolaescu
Level 2

04-02-2021

The short, right answer for the question itself is the apache rewrite NE flag.

The long answer... is that you shouldn't send JSON objects in URLs for many many reasons. Some options:

1. Use a POST

2. Save that JSON in the browser session or local storage and read it on the next page.

3. At least transform that JSON in "normal" URL params and pass that...

 

Avatar

Avatar
Validate 10
MVP
kunal23
MVP

Likes

166 likes

Total Posts

565 posts

Correct Reply

172 solutions
Top badges earned
Validate 10
Validate 1
Ignite 3
Ignite 1
Give Back 50
View profile

Avatar
Validate 10
MVP
kunal23
MVP

Likes

166 likes

Total Posts

565 posts

Correct Reply

172 solutions
Top badges earned
Validate 10
Validate 1
Ignite 3
Ignite 1
Give Back 50
View profile
kunal23
MVP

25-01-2021

I recommend you to pass the JSON object in request body not in query params. And use POST method for these type of requests. 

Avatar

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

591 likes

Total Posts

572 posts

Correct Reply

219 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

591 likes

Total Posts

572 posts

Correct Reply

219 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
BrianKasingli
MVP

25-01-2021

@p0990m,

Within your httpd.conf, you can try to add:

 

AddDefaultCharset utf-8

 

Making sure you have utf-8 encoding enabled.