strange url changing ... |
[eluser]raimon[/eluser]
Hi forum, I'm learning CodeIgniter, and trying to figure out how it works, so I'm playing a little ... Now, if I write this url: http://127.0.0.1/igni/ I get a 404 Page not found, and the url now is: http://127.0.0.1/igni/index.php/login Code: The config.php option is: Code: Inside Controllers, I have a file called index.php: So, any idea why CodeIgniter is changing the URL o why is not going to index.php, inside applications/controllers ? any idea where to lookfor, something that maybe has been changed by me inadvertely ? thanks in advance!! regards, raimon fernandez
[eluser]gtech[/eluser]
Im only guessing but what is your default_controller set to in the config/routes.php? if it is 'login' then that might explain why its jumping to a login controller. [edit] I am not sure if naming a controller Index is a good thing, as each controller may have a function called index.
[eluser]Armchair Samurai[/eluser]
Did you change your default controller to "Index" in routes.php? [edit]gtech beat me to it...[/edit]
[eluser]raimon[/eluser]
[quote author="gtech" date="1195544722"]Im only guessing but what is your default_controller set to in the config/routes.php? if it is 'login' then that might explain why its jumping to a login controller. ok, thanks, that's it, I know it was a really stupid mistake for my part, I had another name there ... [edit] I am not sure if naming a controller Index is a good thing, as each controller may have a function called index.[/quote] ok, I'll change it, you're right. thanks both of you, now it works ... regards, raimon fernandez
[eluser]raimon[/eluser]
well, it was working until now ... I've changed the routes.php: Code: $route['default_controller'] = "welcome"; // "welcome"; the main site is: Code: http://127.0.0.1/igni/ the welcome.php is: Code: <?php the view 'login.php' is: Code: <?= form_open('user/validatelogin/'); ?> and user.php is: Code: <?php the problem: ------------------- after writing 127.0.0.1 as expected, I received the login page. the form tag is: Code: <form action="index.php/user/validatelogin" method="post"> if I submit with missing values, I receive the same login page, but the form tag has changed into: Code: <form action="index.php/user/validatelogin" method="post"> and of course, if I submit again the form, I get a 404 error not found, and the browser's address is: Code: http://127.0.0.1/igni/index.php/user/index.php/user/validatelogin I know the form_open helper puts the url, but I don't understand what I'm doing wrong here ... thanks again for your help, regards r.
[eluser]gtech[/eluser]
you can use base_url() so the full url path can be defined as otherwise it will redirect relative to your controller. Code: <form action="<?=base_url()?>index.php/user/validatelogin"> To use base_url you need to load the url helper in your controller, or in the autoloader.php Code: $autoload['helper']= array('url');
[eluser]raimon[/eluser]
And why CI is putting index.php in the url ? Code: http://127.0.0.1/igni/index.php/user/index.php/user/validatelogin if I remember well, my default page/controller is welcome.php and I'm not using index.php in anyplace ... I'm going to try the base_url() and see ... thanks, r.
[eluser]raimon[/eluser]
If I change this into: Code: $config['base_url'] = "http://127.0.0.1/igni/"; and in the form_open(): Code: <?= form_open(base_url().'user/validatelogin/'); ?> If I write: Code: http://127.0.0.1/igni/ after submitting the form, I get an 404 and the url is: Code: http://127.0.0.1/igni/index.php/http://127.0.0.1/igni/user/validatelogin for the index.php, I see that there is: Code: $config['index_page'] = "index.php"; Maybe CI puts it because some missing controller/parameter ? thanks again ... regards, r.
[eluser]gtech[/eluser]
sorry for the misinfo I shall now stick my fingers in a deep fat fryer so I dont do it again! I read my code and I use somthing like the following Code: <?=form_open('../index.php/user/validatelogin','','');?> or Code: <?=form_open('controller/method');?> this thread should also help you [url="http://ellislab.com/forums/viewthread/65085/"] (see thread for remove index.php)[/url] you need to create a .htaccess file to remove the index.php if you search the forums this has been posted before.
[eluser]raimon[/eluser]
Hello again ... If I use in my view as you mention, I get the famous index.php in the url ... Code: <?=form_open('../index.php/user/validatelogin','','');?>; my config/routes.php has only this: Code: $route['default_controller'] = "welcome"; // "welcome"; where are you using this, in a controller, view ? and what's the purpose of the index.php in the main address? Code: <?=form_open('../index.php/user/validatelogin','','');?> and, if I remove the index.php as this: Code: $config['index_page'] = //"index.php"; my new url for the form action is: Code: hola<form action="AUTO/AUTO/user/validatelogin" method="post"> I'm reading some posts about .htaccess, but I don't understand why I have to change some prefs from the web server for this, maybe I have to re-read again the introduction to code igniter ... thanks for your time ! r. |
Welcome Guest, Not a member yet? Register Sign In |