Jump to content

[HELP] Encode certain URLs


artsrun

Recommended Posts

Hello,

 

Is there a way to encode certain URLs on my page? Lets say i have a forums and in topics i want certain urls to be encoded. Is this possible with something like preg_replace? and encode it to like base64? The urls are going to be something like

 

mysite.com/aaaad4ad

mysite.com/twert78er

mysite.com/rt78ert77

 

and the ending characters are fixed like all urls have 8 ending characters

 

and the results should be something like

 

mysite.com/redirect.php?site=bXlzaXRlLmNvbS9hYWFhZDRhZA==

mysite.com/redirect.php?site=bXlzaXRlLmNvbS90d2VydDc4ZXI=

 

how can i do this?

thanks

Link to comment
https://forums.phpfreaks.com/topic/171384-help-encode-certain-urls/
Share on other sites

Of course you could do that. Wherever your links are generated encode them, wherever there values are used again decode them. Simple.

 

but how can i do this for only certain types of urls, like when users submit a topic in forums, i only want to encode the urls that are links to my site, not like encode their entire topic or links like "google.com"

 

 

I am not sure how mod_rewrite would be in use in this situation?

 

Thanks for the fast replys

but how can i do this for only certain types of urls, like when users submit a topic in forums, i only want to encode the urls that are links to my site, not like encode their entire topic or links like "google.com"

 

This is something you would need to think logically about, we have no idea of your applications structure.

 

For example, can you tell me how I can add an expiry behavior to my User model?

I am not sure you understand what i mean. Here is an example. Lets say this is my forums and i come to this site and make a post and say.

 

"Hi my name is robert and I love http://www.google.com and I found a tutorial on how to fix my car's engine at http://www.phpfreaks.com/12345678"

 

and i make like a preg_replace function of some sort and put it in index.php to get results that would make that message into.

 

"Hi my name is robert and I love http://www.google.com and I found a tutorial on how to fix my car's engine at http://www.phpfreaks.com/redirect.php?site=aHR0cDovL3d3dy5waHBmcmVha3MuY29tLzEyMzQ1Njc4"

 

and the bold part is http://www.phpfreaks.com/12345678 encoded to base64

 

is that possible?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.