Reputation: 1
Recently I published a website and it's working fine. But when I try to open any linked page its URL looks like this:
http://www.englishseekhon.com/English%20Vocabulary%20with%20Hindi%20Meaning.html
As you can see, there are a number of %20
character sequences that I don't want to appear in the URL. How can this be fixed?
Upvotes: 0
Views: 459
Reputation: 1026
Have a look at the code provided here: http://www.asiteaboutnothing.net/c_decode-url.html . The endcode()
and decode()
functions will do the trick.
<script>
function encode() {
var obj = document.getElementById('dencoder');
var unencoded = obj.value;
obj.value = encodeURIComponent(unencoded);
}
function decode() {
var obj = document.getElementById('dencoder');
var encoded = obj.value;
obj.value = decodeURIComponent(encoded.replace(/\+/g, " "));
}
</script>
Upvotes: -1
Reputation: 179246
%20
is the correct percent encoded form of the space character. If you would like to use a "Friendly URL" format, you'll need to replace the spaces in the name of the resource with a different character.
Hyphens and underscores are generally recommended.
A "dasherized" form of the url would be:
http://www.englishseekhon.com/english-vocabulary-with-hindi-meaning.html
Upvotes: 3