CI file structure |
[eluser]Tommy Liu[/eluser]
Dear all, I am newbie of CI. I have one question of CI file structure, please see as below: If I try URL: http://localhost/index.php, it shows controllers/abc.php file which I setup all the files correctly. If I try URL: http://localhost/aboutus.php, I want to shows controllers/xyz.php file. What can I do? Actually, is it possible to do that? Thank you.
[eluser]pistolPete[/eluser]
Read the user guide: http://ellislab.com/codeigniter/user-gui...uting.html
[eluser]Tommy Liu[/eluser]
[quote author="pistolPete" date="1255735398"]Read the user guide: http://ellislab.com/codeigniter/user-gui...uting.html[/quote] Thank you for your help and reply. I try to read it before I post my question. But I still do not understand how to do it. [routes.php] $route['aboutus.php'] = "xyz"; But I need to type URL: http://localhost/index.php/aboutus.php to get the result. Would you mind to post the sample to me? Thank you very much.
[eluser]markup2go[/eluser]
You need to enable mod_rewrite and edit your config.php and set $config['index_page'] = ""; See the URL Helper page of the CI User Guide
[eluser]Tommy Liu[/eluser]
[quote author="markup2go" date="1255736821"]You need to enable mod_rewrite and edit your config.php and set $config['index_page'] = ""; See the URL Helper page of the CI User Guide[/quote] Thank you for your reply. I read it already. But it does not show how to setup or config for typing URL: http://localhost/aboutus.php route to controllers/xyz.php. Thank you.
[eluser]markup2go[/eluser]
Code: $route['aboutus.php'] = "xyz"; Please paste your .htaccess and make sure you have xyz.php in system/application/controllers and that has an index() function. Or tell us what it the current behavior when you type that url in your browser.
[eluser]Dan Horrigan[/eluser]
Actually it does. You said you have it working as http://localhost/index.php/aboutus.php and the CodeIgniter URLs page has a section called "Removing the index.php file". Read that section. If you need more info on how this works do a google search for mod_rewrite and .htaccess. Don't forget this either when removing the index.php part: [quote author="markup2go" date="1255736821"]edit your config.php and set $config['index_page'] = ""; [/quote] Doing both of these steps (the .htaccess and the config file edit) will allow you to go to http://localhost/aboutus.php Dan
[eluser]Tommy Liu[/eluser]
[quote author="Dan Horrigan" date="1255737910"]Actually it does. You said you have it working as http://localhost/index.php/aboutus.php and the CodeIgniter URLs page has a section called "Removing the index.php file". Read that section. If you need more info on how this works do a google search for mod_rewrite and .htaccess. Don't forget this either when removing the index.php part: [quote author="markup2go" date="1255736821"]edit your config.php and set $config['index_page'] = ""; [/quote] Doing both of these steps (the .htaccess and the config file edit) will allow you to go to http://localhost/aboutus.php Dan[/quote] Thank you. I can get the result successfully!!!
[eluser]Tommy Liu[/eluser]
I have one more question that is I want to type URL: http:\\localhost\user_guide\, but it cannot show the CI user guide homepage. What can I do? Thank you.
|
Welcome Guest, Not a member yet? Register Sign In |