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

  • SEARCH
  • Home
  • 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 3674594
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:52:25+00:00 2026-05-19T02:52:25+00:00

Started my first CI project and am just wondering how I handle URL parameters?

  • 0

Started my first CI project and am just wondering how I handle URL parameters? I have a controller named ‘city’, and I’ve modified my mod_rewrite so localhost/codeigniter uses rewrite to localhost/codeigniter/city. What I want to do is add a city name onto the end of the URL and use get segment to query a table.

So my example would be localhost/codeigniter/edinburgh. I would grab the last segment and then create the sql query. However I think when I put edinburgh into the URL CI thinks I’m looking for a controller called ‘edinburgh’.

Do I have to add routing in or something similar?

  • 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-19T02:52:26+00:00Added an answer on May 19, 2026 at 2:52 am

    You can indeed use routing to do this.

    $route[‘:any’] = “controller/method”;

    This will redirect EVERYTHING after your base url to the specified controller and method inside that controller. To get the url segments you can use the URI helper.

    $this->load->helper(‘url’); // load the helper first

    $city = $this->uri->segment(1);

    When accessing http://localhost/codeigniter/edinburgh the $city variable in above example would be edinburgh.

    Hope that helps!

    PS. You don’t need mod_rewrite to specify a default controller. You can set it in your config.php under Routes. Specify city as your default controller and you can get rid of the mod_rewrite.

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

Sidebar

Related Questions

I have just started my first project on GeoDjango. As a matter of fact,
So I just started my first rails project yesterday. I had two many-to-many (has_and_belongs_to_many)
I just started my first Mercurial project. I did a 'cd' into my source
I just started to develop my first android project. I want to add a
I just started working on my first Visual Studio project, and I imported all
Just started my first WCF rest project and would like some help on what
I have started learning Ruby and just tried out my first hello world program
I am new to asp.net and just started my first project. I heard about
I just started on my first JavaScript project which is a small script to
I have a Rails 3.2 project I just started, and I'm trying to write

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.