0

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?

DavidRR
  • 18,291
  • 25
  • 109
  • 191
  • 4
    Replace the spaces in that HTML file's name with something else (like underscores). The `%20` is a URL-encoded space character. – David Oct 10 '14 at 23:12

2 Answers2

3

%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
zzzzBov
  • 174,988
  • 54
  • 320
  • 367
  • And how about the URL of this very page? :-) – DavidRR Oct 11 '14 at 00:18
  • url cannot contain SPACES. and if you dont remove spaces in your coding with other characters I think you can never do what you want. What do you want actually ? show spaces in the URL of page in the address bar ? – Meer Oct 11 '14 at 02:04
  • @Meer, I'm not sure I understand what you're trying to say. "url cannot contain SPACES" isn't quite accurate. URLs regularly contain spaces, but they're percent encoded to `%20`, so they don't appear as a space character. – zzzzBov Oct 11 '14 at 04:13
  • @Meer - Did you intend to comment on the OP's question rather than on this answer? – DavidRR Oct 11 '14 at 14:22
-1

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>
DavidRR
  • 18,291
  • 25
  • 109
  • 191
Meer
  • 1,006
  • 10
  • 15