artsrun Posted August 22, 2009 Share Posted August 22, 2009 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 Quote Link to comment Share on other sites More sharing options...
trq Posted August 22, 2009 Share Posted August 22, 2009 Of course you could do that. Wherever your links are generated encode them, wherever there values are used again decode them. Simple. Quote Link to comment Share on other sites More sharing options...
Garethp Posted August 22, 2009 Share Posted August 22, 2009 Sounds like you need http://www.workingwith.me.uk/articles/scripting/mod_rewrite Quote Link to comment Share on other sites More sharing options...
artsrun Posted August 22, 2009 Author Share Posted August 22, 2009 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" Sounds like you need http://www.workingwith.me.uk/articles/scripting/mod_rewrite I am not sure how mod_rewrite would be in use in this situation? Thanks for the fast replys Quote Link to comment Share on other sites More sharing options...
trq Posted August 22, 2009 Share Posted August 22, 2009 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? Quote Link to comment Share on other sites More sharing options...
artsrun Posted August 22, 2009 Author Share Posted August 22, 2009 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.