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

The Archive Base Latest Questions

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

I am trying to create a URL shortener using CodeIgniter 2. I have 2

  • 0

I am trying to create a URL shortener using CodeIgniter 2.

I have 2 controllers: main and api.

For redirecting a short link through the router, I am using this setting in config/routes:

$route['(.*)'] = "main/$1";

along with a method in the main controller which should work. However, the controllers won’t start. Please help me to solve this problem.

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

    You controller “any” isnt called because it falls into that regex, so it’s routed to main.
    In order to exclude “any” from this rule you need to create a special rule for that, keeping in mind that for CI rules are cascading , so they’re executed in the order they’re presented

    Note: Routes will run in the order
    they are defined. Higher routes will
    always take precedence over lower
    ones.

    So, you would have:

    // reserved routes must come before custom routes
    $route['default_controller'] = "home";
    $route['404_override'] = '';
    $route['any'] = //your rule here. maybe "any". ?
    $route['(.*)'] = "main/$1";  // CI also provides you with `(:any)` rule, that mateches any character.
    

    More on this here: Uri routing

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

Sidebar

Related Questions

I am trying to create a URL friendly link from a string. Instead of
Im trying to shorten a url using ggole api's.Here is my php code .It
I am trying to create a url router in PHP, that works like django's.
I'm using Rails 3 and ruby 1.9 I'm trying to create a customized URL
I am trying to create URL connection using a proxy at run time. My
So i'm trying to POST something to a webserver. System.Net.HttpWebRequest EventReq = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url); System.String
I'm trying to create user profiles for my site where the URL is something
I am trying to create a validation that checks to make sure a domain/url
I am trying to create a route with a Username... So the URL would
I'm trying to learn Regex & URL Rewriting in PHP. How can I create

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.