Using Mod_Rewrite and _Remap in 2.x |
[eluser]Lakestone[/eluser]
I have an old CI application that I'm trying to port to the latest version. All I want to is to take in the first segment of the welcome page and then remap: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Since 'Start' is my main controller, the url will look like "localhost/app1/". And if I type into the address bar "localhost/app1/contact" it should use the main controller but call the contact function. Can I accomplish this without using mod rewrite? If not, this is the current .htaccess code that I use: Code: RewriteEngine On What else is missing? I keep getting "Not Found - The requested URL /index.php/Start/contact was not found on this server." Cheers
[eluser]Aken[/eluser]
Mod rewrite is meant to remove the index.php function only, so you can remove anything specific involving your app from that. There's a lot of different ways to handle and direct requests - you should explain more about what pages do and don't need to be routed, because using a single controller function to handle requests can be cumbersome and often unnecessary.
[eluser]Lakestone[/eluser]
Hi Aken, I'd like to be able to use more than one controller for sure. But right now I cannot seem to access any other method inside my controller by using the URL app1/controller/method, I still have to (even with the mod rewrite), use app1/index.php/controller/method. So do I need to update my htaccess file or is the problem laying somewhere else?
[eluser]Aken[/eluser]
Your .htaccess is the problem. Try this: Code: RewriteEngine On
[eluser]Lakestone[/eluser]
[quote author="Aken" date="1331075940"]Your .htaccess is the problem. Try this: Code: RewriteEngine On Same result, but shorter: http://localhost/start/contact Not Found The requested URL /index.php/contact was not found on this server.
[eluser]CroNiX[/eluser]
Do you have any routes? You request /start/contact but it looks like it's going straight to contact, so it looks like a route or something might be interfering.
[eluser]Lakestone[/eluser]
The only route I am using is: $route['default_controller'] = "start"; If you got a clean install of CI with necessary tweaks like a .htaccess file - that is working like I want it, feel very free to zip it and upload it. I'd be extremely thankful, this is starting to annoy me quite a bit now |
Welcome Guest, Not a member yet? Register Sign In |