Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6838377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:35:22+00:00 2026-05-26T23:35:22+00:00

Say I have a social network which accepts: short url’s using the nickname: e.g.

  • 0

Say I have a social network which accepts:

short url’s using the nickname: e.g. -> http://www.mynetwork.com/john.doe
256 bit AES hashes: e.g. -> http://www.mynetwork.com/23fdgfdjhdbfuyviofhedfbncxgersbzc34…

i want to route them to a single controller like ‘Profile’ wherein:

the short url’s version goes to a function like: fetch($nick) in which,
i hash the nick to aes, then make a redirect to call the a function: view($hash)

the view function is the one that actually has the logic for something like displaying that user’s profile.

this ensures that whatever the case in which url i choose to visit a profile, whether short url or hash, i always end up getting redirected to the hash url call…

how can i do that? i am thinking it’s something to do with routes but i am a little lost on how to go about with it…

to make it short, accessing:
http://www.mynetwork.com/john.doe redirects to: http://www.mynetwork.com/23fdgfdjhdbfuyviofhedfbncxgersbzc34 and displays that user’s profile

and of course, directly accessing http://www.mynetwork.com/23fdgfdjhdbfuyviofhedfbncxgersbzc34 will simply display the user’s profile

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:35:23+00:00Added an answer on May 26, 2026 at 11:35 pm

    If you’re not willing to use different URL’s for the different functions, like this:

    www.mynetwork.com/nick/john.doe
    www.mynetwork.com/hash/23fdgfdjhdbfuyviofhedfbncxgersbzc34
    

    Then, you’ll have to write a function that can diffrentiate between a nick and a hash. In your examples, CodeIgniter sees this for both, nick and hash:

    www.mynetwork.com/{someArg}
    

    You could do something like this:

    www.mynetwork.com/view/nickOrHash
    

    The controller:

    class View extends CI_Controller
    {
        public function index($arg)
        {
            if (strlen($arg) < length_of_hash)
            {
                viewByNick($arg);
            }
            else
            {
                viewByHash($arg);
            }
        }
    
        public function viewByNick($arg)
        {
        }
    
        public function viewByHash($arg)
        {
        }
    }
    

    You will also have to edit your URI routing for CodeIgniter so it sends nickOrHash as an argument to index and does not search for a function called nickOrHash under the view controller (http://codeigniter.com/user_guide/general/routing.html)

    In the above code, replace length_of_hash with the length a 256 bit AES hash will always have

    EDIT:

    Another, more reliable way of determining whether the argument is a nick or hash, could be:

    1. You receive argument. Check in database if user with a hash of the argument exists. If exists, call viewByHash($arg)
    2. If not exists, hash the $arg,and check database again if user with the new hash exists. If exists call viewByHash(newHash) with the calculated hash.
    3. If not exists, error 404

    Routing:

    $route['view/(:any)'] = "view/index/$1";
    

    If a user requests url mynetwork.com/view/arg, codeIgniter will call index() method in view controller passing the last part of the user’s request URL as the argument.

    You can change it to something like this, if you want to check by hash directly:

    $route['view/(:any)'] = "view/viewByHash/$1";
    

    If above function fails, then check by username, etc etc

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a social network so a blog is only you could say a
I'm currently making my own social network and I have a php problem which
For a very large site such as a Social Network (say Facebook), which method
I am working on a social network type project, as most social networks have,
Hi I am building a social network in dreamweaver using php and sql as
Ok lets say I'm making a social networks like twitter. I have a table
I have a social network that allows users to post blogs, ask questions, and
Let's say I have a case class that represents personas, people on different social
I have opened a large web project on elance for a social network. I
Lets say have this immutable record type: public class Record { public Record(int x,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.