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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:28:12+00:00 2026-05-27T21:28:12+00:00

i need to create an url like this: www.example.com/index.php/scheda/name-surname-id.html so i create the Scheda

  • 0

i need to create an url like this: http://www.example.com/index.php/scheda/name-surname-id.html

so i create the Scheda controller, this is the code:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Scheda extends CI_Controller{

    function __construct(){
        parent::__construct();
    }

    function index(){
        $name_scheda = $this->uri->segment(2);
        //i need only the id for the search into db
        $id = substr($name_scheda, strripos($name_scheda,'-')+1, strlen($name_scheda));

        echo "name:".$id;
    }
}

but when i write the url in the address bar i get an 404 error…can someone help me to understand why?

  • 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-27T21:28:13+00:00Added an answer on May 27, 2026 at 9:28 pm

    Your url:

    www.example.com/index.php/scheda/name-surname-id.html
    

    Should be:

    www.example.com/index.php/scheda/index/name-surname-id.html
    

    index() is the default method, but the index segment can only be missing from the URL if there are no arguments, otherwise Codeigniter will think you are trying to call the method name-surname-id.html().

    You can use routes.php or _remap() to clean up the URL and remove the index segment.

    // routes.php
    $routes['scheda/(:any)'] = 'scheda/index/$1';
    

    OR:

    class Scheda extends CI_Controller{
    
        function _remap($method, $args) {
            $name_scheda = $method;
            $id = substr($name_scheda, strripos($name_scheda,'-')+1, strlen($name_scheda));
            echo "name:".$id;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create this url: www.example.com/directory/[state]-financial-planners Where [state] will be different depending on
Currently, I have URLs that look like this: http://www.example.com/user/create http://www.example.com/user/edit/1 But now, I have
In my code, I create a link like this: $link = 'http://www.mydomain.com/'.urlencode($str).'/1'; I use
Okay.. so basically, say we have a link: $url = http://www.site.com/index.php?sub=Mawson&state=QLD&cat=4&page=2&sort=z; Basically, I need
So basically I have a very long url, something like this - http://www.site.com/wp-content/themes/theme/timthumb.php?src=/wp-content/uploads/2012/random-image-name.jpg&w=650&h=0&zc=1&q=100 and
i need create a variable with parent subclass. Example: Parent Class <?php class parentClass
I need to create an ASP.NET application to access a URL, when this application
imagine this url: http://www.youtube.com/watch?v=6n8PGnc_cV4&feature=rec-LGOUT-real_rn-2r-13-HM what is the cleanest and best regexp to do the
I need some help in PHP to create short urls just like StackOverflow creates
I found this post http://www.netmagazine.com/tutorials/create-jquery-tab-system And modified this tabs to fit my current design.

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.