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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:56:31+00:00 2026-06-03T00:56:31+00:00

I am using Codeigniter and want to have SEO-friendly URLs. There will be 2

  • 0

I am using Codeigniter and want to have SEO-friendly URLs. There will be 2 types of URI segments, http://www.domain.com/view/193847 and http://www.domain.com/view/193847-canon-5d-mark-iii.

If the first URL is used, function view_mini is called and passed the product id 193847. If the 2nd one is used, function view_full will be called and passed the same product id 193847.

Problem: How can I differentiate between the 2 URLs? Or is this an inferior approach to solve the problem?

PHP How should the if condition be structured?

function view($pid) {
    if($this->uri->segment(2) == something) {
        $this->view_mini($pid);
    } else {
        $this->view_full($pid);
        }
}

function view_mini($pid) {
   // ...
}

function view_full($pid) {
   // ...
}

EDIT

I am using URL routing to route http://www.domain.com/controllername/view/1234 to http://www.domain.com/view/1234

  • 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-06-03T00:56:33+00:00Added an answer on June 3, 2026 at 12:56 am

    you can use the regular expression to check the segment if it has anything other than numbers, then you can execute the view that you want for example

    $pattern = '\d[0-9][^a-zA-Z]';
    $url = $this->uri->segment(2);
    if(preg_match($pattern,$url))
    {
    //this will match only the numbers
    
    $this->view_mini($pid);
        } else {
            $this->view_full($pid);
        }
    

    i hope this will help ..

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

Sidebar

Related Questions

I have a very AJAX-ish listing webpage created using Codeigniter where I want registered
I am using codeigniter, I have URL like this ( http://localhost/en/home/submit ). My App
We have a popular web-app developed using CodeIgniter. Now we want to expose our
I am developing a website using Codeigniter that will have different subdomains for different
I have a little problem with array. Im using codeigniter. What i want to
I'm using CodeIgniter and .htaccess to rewrite the URLs but I want it to
I am using Codeigniter (for the first time). I want to have the URL
I have created a basic CMS using CodeIgniter 2.0.3, and now I want to
I'm using CodeIgniter, and will likely use their template library as I want to
I am using CodeIgniter with version 2.1.0. I want to use Hooks for login

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.