We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,731 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Website url encode

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?

4
Contributors
11
Replies
1 Week
Discussion Span
3 Months Ago
Last Updated
17
Views
DamzWildfire
Junior Poster in Training
51 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 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

gon1387
Posting Whiz in Training
233 posts since Jan 2011
Reputation Points: 32
Solved Threads: 37
Skill Endorsements: 3

add this code within a javascript function?

DamzWildfire
Junior Poster in Training
51 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

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

diafol
Keep Smiling
Moderator
10,634 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,506
Skill Endorsements: 57

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.

DamzWildfire
Junior Poster in Training
51 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 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.

pritaeas
Posting Prodigy
Moderator
9,265 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,456
Skill Endorsements: 86

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

DamzWildfire
Junior Poster in Training
51 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

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

pritaeas
Posting Prodigy
Moderator
9,265 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,456
Skill Endorsements: 86
DamzWildfire
Junior Poster in Training
51 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 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.

pritaeas
Posting Prodigy
Moderator
9,265 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,456
Skill Endorsements: 86

as a form a security

DamzWildfire
Junior Poster in Training
51 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 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.

pritaeas
Posting Prodigy
Moderator
9,265 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,456
Skill Endorsements: 86

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.1073 seconds using 2.78MB