0
votes

UPDATE

If I browse url like

localhost/myapp/index.php/about_us/index

it works. What is this index.php in url? Do I need to mention it in some config file so that it gets appended and forms correct url in menu/links on site?

Original Question

I have no knowledge of PHP but I got a project which in php (codeigniter) to convert in Ruby on Rails. I could set up db and application well, when I browse application with base url(without mentioning controller & action) it loads page properly. But as soon as I mention url like

localhost/myapp/home/index

it shows message

The requested URL was not found on this server.

If I change default controller to anything in routes.php that page with index method works fine but not with explicit mentioning controller and action.

I am not sure what is the issue, I don't know how routing works in php :(

Any help will be appreciated.

2
you dont know php and ur looking for rails routing ???? - swapnesh
What is your web root? localhost/myapp/? If so, do you have home controller with index action? - Timur
@pramodtech both[Rails/codeigniter] are using MVC design pattern so conceptual part is more or less the same - swapnesh
@Timur web root is localhost/myapp/ and yes I do have home controller with index action - pramodtech
@swapnesh yes, I understand it and that's why confused on why explicit url doesn't work. - pramodtech

2 Answers

0
votes

In CodeIgniter, all requests are directed through the index.php file, which acts like a front controller.

index.php must be present in the URL unless you have created a solution to eliminate it. When using Apache, that is typically done with an .htaccess file. There are hundreds of articles and questions regarding this technique -- certainly you can find something to help you.

In regards to URLs and a config option for defining index.php, CodeIgniter URL helper functions such as site_url() utilize the config setting $config['index_page'] found in application/config/config.php. If you remove index.php from your URLs using an .htaccess solution, you can make this setting blank:

$config['index_page'] = '';

This setting is useful for when you want to rename index.php to something else, as well (not very common).

0
votes

It seems that you had not configured your web server properly. See this question for details for Apache: routing problem in codeigniter

And here are rules for nginx: http://wiki.nginx.org/Codeigniter