Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

the use of `%3F` in URL

Tags:

html

url

While moving a website - that I did not build - I have run into the use of %3F.

%3F is the percent-encoded version of ?.

It seems to be used like this a lot:

<ahref="example%3Flang=1.html">Example</a>

when linking to a file named example_lang=1.html.

So, I replaced %3F with _, and all works again.

I am missing something here. The old website worked. After being moved, it no longer worked. After the replacement of %3F to _, the links worked again. Why?

like image 974
Flummox - don't be evil SE Avatar asked Dec 29 '16 13:12

Flummox - don't be evil SE


1 Answers

First, you should elaborate your question to understand it better after all If I understood it correctly then this might be the answer.

"_" is not a reserved URI character.

As you said that %3F is reserved for "?" then you are absolutely right but if you read the documentation written on wiki states that "_"(underscore) is not a reserved URI character.

So that for example if the URL for a web page is "example_test.html" then its encoded URL must be "example_test.html" if there is not any mechanism applied on that URL. Now I will take an another example of PHP based web page that may answer your question.

In PHP there is a function "str_replace" that is used to replace the string by programmer defined characters or string.

Let assume that I have a page named "example_test.html" and for some xyz reasons I want to change it to "example%3Ftest.html" then I can use

str_replace("%3F","_","<a href='example%3Ftest.html'>Example Test</a>");

This function will search for all occurences of "%3F" and replace it with "_" in provided string(here "href=example%3Ftest.html") and output as "href='example_test.html" which is the actual link for my file.

like image 135
sagar Avatar answered Nov 15 '22 22:11

sagar