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 7411563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:24:21+00:00 2026-05-29T06:24:21+00:00

I’m really stuck in doing routes for my app and I find rooting in

  • 0

I’m really stuck in doing routes for my app and I find rooting in CI very confusing
so what I have is some pages of people in each country, and you get to that page by selecting a country in a drop list in the home page
I manage to pass data using POST method, but the problem is I can’t access these pages directly by a url, because their main controller do access to db and generate them
so for now all my pages have this url

www.site.com/country 

country is a controler

but i want is to look like this:

www.site.com/name-of-country/name-of-person

any idea how to do that?

  • 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-29T06:24:21+00:00Added an answer on May 29, 2026 at 6:24 am

    These answers don’t give enough info, and the accepted answer is just terrible…

    The best way to handle this would be to set up your routing to do the following (if you want to control the countries that the users are able to use:

    put this in your routes file:

    foreach(array('country1', 'country2') as $country) { // array with allowed countries
      $routes[$country.'/(:any)'] = "country/view/{$country}/$1";
      $routes[$country] = "country/view/{$country}";
    }
    

    what this does is takes your array of allowed countries and then creates a routing rule for each country, so if a user goes to http://example.com/japan/naruto, it routes to the url http://example.com/country/view/japan/naruto. This is assuming that ‘japan’ is in your ‘allowed countries’ array.

    The second one simply routes the url http://example.com/japan to http://example.com/country/view/japan

    into your controller country.php:

    class Country extends CI_Controller {
      function view($country, $username = false) { // $username=false allows you to show just a 'country' page if you want to
        if ($username) {
          $this->load->view('users_view', array('country' => $country, 'username' => $username));
        } else {
         $this->load->view('countries_view', array('country' => $country)) 
        }
      }
    }
    

    what I have done here is enabled you to create a page just for the country that is displayed which loads the countries_view.php out of your views folder, or you can view the page for the user, which loads the users_view.php page.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.