Problem setting routes in HMVC |
Hello guys,
I am quite new to CodeIgniter and MVCs. I started working on this new project and installed the HMVC from wiredesignz . I encounter a HMVC routing problem and this thing drives me CRAZY! My problem is that my routing is not working properly. I write you the details of my CI3 project. application/config config.php PHP Code: $config['base_url'] = 'http://localhost/Hub2/'; routes.php PHP Code: //$route['(:any)'] = 'pages/view/$1'; application/modules/authentication/controllers/Login.php application/modules/authentication/model/User.php application/modules/authentication/view/login_box.php application/modules/pages/controllers/Pages.php application/modules/pages/view/template/....... my .htacess from the root directory Code: <IfModule mod_rewrite.c> Here is my Login Class: PHP Code: <?php MY_Controller PHP Code: class MY_Controller extends MX_Controller When I can access the following links: http://localhost/Hub2/ returns me correctly the Modules/Pages/Controllers/Pages/View http://localhost/Hub2/login returns me Not Found. The requested URL /Hub2/login was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. http://localhost/Hub2/awesome returns me Not Found. The requested URL /Hub2/awesome was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. http://localhost/Hub2/index.php/login returns me correctly the Modules/Authentication/Controllers/Login/Index http://localhost/Hub2/index.php/awesome returns me correctly the Modules/Pages/Controllers/Pages/Index
For one you are specifying the index method in your route, this is not needed due to the fact that the index method is called as the default method.
Your default controller is wrong - You can NOT use a directory as a part of this setting! What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(05-30-2016, 04:02 AM)InsiteFX Wrote: For one you are specifying the index method in your route, this is not needed due to the fact that the index method is called as the default method. Thank you for replying, I really appreciate it. Unfortunately I did not really understand your points. Can you point out the lines where I am doing wrong. Best regards PHP Code: // This only takes a method no directories are allowed If you need like cms pages then I use this in the controller: PHP Code: // See the URI Class library in the CodeIgniter Users Guide. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(05-30-2016, 10:12 AM)InsiteFX Wrote:I did the changes and I still have the same 404 message when I access http://localhost/Hub2/login Not Found. The requested URL /Hub2/login was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. When I access http://localhost/Hub2/index.php/login it works like before getting my login index method but definitely is not what I want. What will be the difference with this new code from here? [quote pid='332863' dateline='1464628329'] If you need like cms pages then I use this in the controller: PHP Code: // See the URI Class library in the CodeIgniter Users Guide. [/quote]
Try this .htaccess file, it's from the FuelPHP and works very well:
Code: <IfModule mod_rewrite.c> The code I showed you for the CMS Pages allow you to grab the segments by the number /1/2/3/4 etc; What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(05-31-2016, 08:35 AM)InsiteFX Wrote: Try this .htaccess file, it's from the FuelPHP and works very well: I appreciate your input. I did the change, but it is still not working. When I try to access: http://localhost/Hub2/login I get a new error: Not Found. The requested URL /Hub2/login was not found on this server. I can access the following addresses (like before) http://localhost/Hub2/ and http://localhost/Hub2/index.php/login
It looks like you need to update your RewriteBase, also. Currently it will think your website root is in /localhost, I believe, when yours is actually in a subfolder. Try changing it's value in .htaccess to :
Code: RewriteBase /Hub2
Any time you make changes it is aa good idea to restart everything.
Change your route.php to look like this one. PHP Code: // This route cannot have a directory name! What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |