PHP CodeIgniter URL导航问题

我是CodeIgniter的新手,也有普通的PHP知识。 上周开始学习CodeIgniter并遇到了一个我无法克服的基本问题。 我的开发环境是(OS,PHPStorm,MAMP,APACHE)。 CI项目根目录是 http:// localhost:63342 / CodeIgniter / ,此地址加载我的'default_controller'(登录 Controllers文件夹中的.php)。 此控制器将我重定向到我的视图“$ this-&gt; load-&gt; view('login_view');”。 在我的视图中,我有一个带有这一行的表单:在提交表单时,它应该将我带到Controller中的form.php,但事实并非如此! 当我提交时,我被带到了一个网址: http://127.0.0.1/CodeIgniter/form ,但有错误 消息“连接尝试127.0.0.1被拒绝。”。 </ p>

此外,当我尝试输入网址(即BASE_URL()。/ index.php / form)或amy其他网址时,我也会收到错误。 我的印象是,在CI中浏览页面就像在Controller文件夹中键入文件名及其中的方法一样简单。 我在这里失踪了什么? 任何通过URL导航的尝试都会出现“404 Not Found”错误。 我相信我错过了一些非常简单的东西,但我无法弄清楚是什么。 我已阅读文档并在网上搜索,但未找到答案。 我已经在root中更改了.htdaccess,在Apache中尝试了启用模式,在Config.php,routes.php等中完成了所有必要的更改。如果你能告诉我在这里做错了什么,我将不胜感激。 我并不期待让CI开始这么难:s </ p>

欢呼</ p>
</ div>

展开原文

原文

I am new to CodeIgniter and also have average PHP knowledge. Just started learning CodeIgniter last week and having a basic problem which i can't overcome. my development environment is (OS,PHPStorm,MAMP,APACHE). CI project root is http://localhost:63342/CodeIgniter/ and this address loads my 'default_controller' (login.php in Controllers folder). this controller redirect me to my view "$this->load->view('login_view');". in my view i have a form with this line: which supposed to take me to my form.php in Controller upon the form being submitted but it does not! when i submit i am taken to a url : http://127.0.0.1/CodeIgniter/form with error message "connection attempt to 127.0.0.1 was rejected.".

Also when i try to type a url (i.e. BASE_URL()./index.php/form) or amy other URL in fact, i get errors too. i was under impression that navigating through pages in CI is as simple as typing the name of the file and the method in it in my Controller folder. what am i missing here? any attempt to navigation through URL i get "404 Not Found" error. i am sure i am missing something very simple here but i can't figure out what. i have read the documentations and search the web and no answer is found. i have changed the .htdaccess in root, tried the enable mode in Apache, done all the necessary changes in Config.php , routes.php etc. i would appreciated it if you can tell what am i doing wrong here. i wasn't expecting getting started with CI to be this hard :s

cheers

duanpaxin3531
duanpaxin3531 在codeigniter3版本中,最好设置你的基本网址示例:$config['base_url']='http://localhost/your_project/';即使不是要求,但如果留空则会遇到一些错误。
4 年多之前 回复

2个回答



您重定向时似乎“松散”了端口(63342)。 你的表格有什么作用? 如果这是“ http:// localhost / CodeIgniter / form ”的网址,则应添加端口:< a href =“http:// localhost:63342 / CodeIgniter / form”rel =“nofollow”> http:// localhost:63342 / CodeIgniter / form </ p>
</ div>

展开原文

原文

It seems you "loose" the port (63342) when you redirect. What is the action of your form? If this is an url like "http://localhost/CodeIgniter/form", you should add the port : http://localhost:63342/CodeIgniter/form



您可以使用URL帮助程序输出设置登录表单的操作。</ p>

   site_url('form')
</ code> </ pre>

http://www.codeigniter.com/user_guide/helpers/url_helper.html?highlight=site_url#site_url </ p>
</ div>

展开原文

原文

You can output set your login form's action by using the URL helper.

site_url('form')

http://www.codeigniter.com/user_guide/helpers/url_helper.html?highlight=site_url#site_url

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐