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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:37:28+00:00 2026-06-18T02:37:28+00:00

I want to use mod_rewrite with PHP, parse the URL with this format: http://www.domain.com/Path-to-index.php/Class_to_Load/Function_to_Execute/Arguments_as_array_to_the_function

  • 0

I want to use mod_rewrite with PHP, parse the URL with this format:

http://www.domain.com/Path-to-index.php/Class_to_Load/Function_to_Execute/Arguments_as_array_to_the_function

The class to load will be included of the directory classes, with a strtolower then ucfirst, like:

http://www.domain.com/Path-to-index.php/SAMPLE will include classes/Sample.php and execute the function action_index, because no function was used.

Then, when this url is open: http://www.domain.com/Path-to-index.php/SAMPLE/Login/User, PHP should include classes/Sample.php and execute action_Login($args = Array(0 => "User"));.

Please I need to know 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-06-18T02:37:29+00:00Added an answer on June 18, 2026 at 2:37 am

    Your index.php could look something like this:

    // @todo: check if $_SERVER['PATH_INFO'] is set
    $parts = explode('/', trim($_SERVER['PATH_INFO'], '/')); // get the part between `index.php` and `?`
    
    // build class name & method name
    // @todo: implement default values
    $classname = ucfirst(strtolower(array_shift($parts)));
    $methodname = "action_" . array_shift($parts);
    
    // include controller class
    // @todo: secure against LFI
    include "classes/$classname.php"
    
    // create a new controller
    $controller = new $classname();
    
    // call the action
    // @todo: make sure enough parameters are given by using reflection or default values
    call_user_func_array(Array($controller, $methodname), $parts);
    

    Your .htaccess for removing index.php from the url:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
    

    It’s always interesting to roll your own framework to learn more about PHP, but if you are really coding something bigger, I highly recommend using a well-known and well-documented framework. There are a lot of good frameworks out there, which are well-tested and used in production before. Just take a look at all the @todo notices above. These are all issues, which are already handled by a framework and you don’t need to care about these things.

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

Sidebar

Related Questions

Currently I have a url like this http://<client_name>.website.com/index.php?function_name&cat=32 I want to set things up
Changed my url from http://www.website.com/b.php?n=45&t=example to this http://www.website.com/45/example by using this mod_rewrite RewriteEngine On
I want to rewrite an url like this: http://www.piata-bio.ro/presa-bio.php?var1=http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNHmU7U7bXtlH9Lo8dXfBs64PqxgbA&url=http://www.eva.ro/divertisment/stiri/un-nou-concept-de-magazin-articol-35491.html to something like this :
i having a URL http://www.domain.com/wp/application/?productname I want to change it to http://www.domain.com/wp/application/productname . if
So I want to use mod_rewrite to transform: random_name.com/main.php?user=$user into random_name.com/$user (the $user is
I have this url structure: proyectos.example.com/ci-doctrine/index.php proyectos.example.com/ci-doctrine/index.php/welcome proyectos.example.com/ci-doctrine/index.php/blog proyectos.example.com/ci-doctrine/admin.php proyectos.example.com/ci-doctrine/admin.php/welcome proyectos.example.com/ci-doctrine/admin.php/dashboard For index.php urls,
I know how to make URL's rewrite, for example: www.example.com/index.php?id=1&cat=3 to www.example.com/1/3/ (or whatever).
I want to change url for example http://localhost/mysite/index.php?page=about will become http://localhost/mysite/index/about I also used
Let's start with an example: So requested URL would be: www.domain.com/product/hdd/samsung I want to
Okey, so this is my problem. I want to use mod_rewrite to make nice

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.