Website url encode

 
0
 

hey i want to encode my website url as a form of security but i have no idea how to go about doing so and help?

 
0
 

In javascript you can encode your url like this:

var DWUrl = "http://www.daniweb.com";

//output: http://www.daniweb.com
console.log(encodeURI(DWUrl));

//output: http%3A%2F%2Fwww.daniweb.com
console.log(encodeURIComponent(DWUrl));

here's the description for the two func:
Encode URI
Encode URI Component
Decode URI
Decode URI Component

 
0
 

add this code within a javascript function?

 
0
 

I'm unsure as to the use here. Could you give an example of what you're trying to accomplish?

 
0
 

is this the correct way the encode a browser url:

<script>
    function test()
    {

        $string= 'http://www.google.com';
        urlencode($string);
    }
</script>

Basically i have a website and i want to encode the url when it it shown in the browser.

 
0
 

No, you are mixing Javascript and PHP, not possible.

I think you misunderstand what URL encoding is. You can encrypt parts of an URL, but not the complete one. It's better if you explain WHY you want to do this.

 
0
 

basically i want to encode parts of the url when shown in the browser eg. mydomain.com/index.php. i wouldnt want the index.php to show. want use it as a means of security

 
0
 

Can you give an example of what you DO want to show, and how it should be processed?

 
0
 

something like this maybe:

http://www.example.com/-d%C3%B4n-s%C3%AC-%C3%A0
 
0
 

With htaccess you can process all these with a single script, and do the decryption and redirect there. Am lost as to WHY you would want this.

 
0
 

as a form a security

 
0
 

Am not sure WHAT you are trying to secure. Just "securing" some URL parameters doesn't sound like a plan. If you are using sensitive data, use POST, and SSL.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article