简体   繁体   English

CodeIgniter中的Base_url无法正常工作

[英]Base_url in CodeIgniter is not working

I have some form like this 我有这样的形式

<form action=<?php base_url('logincontroller/loginaction');?>  method=post >

by using base_url as 通过使用base_url作为

$config['base_url']="localhost/testsite/index.php";

If I give like this it works just fine. 如果我这样给它,那就很好了。

But I know it is not the correct way for giving base_url if i give base_url as. 但是我知道,如果我给base_url作为,这不是给base_url的正确方法。

$config['base_url']="localhost/testsite/";

Like this when i click submit it will come up with error that page not found what should i do to get it work? 像这样,当我单击提交时,它将出现错误,该页面未找到我应该怎么做才能使其正常工作?

You need to change your .htaccess file in your project root folder. 您需要在项目根文件夹中更改.htaccess文件。 Here is the line that you need to add after RewriteEngine On : 这是在RewriteEngine On之后需要添加的行:

RewriteRule ^(.*)$ index.php/$1 [L]

And also enable rewrite in your apache by issuing this command in terminal: 还可以通过在终端中发出以下命令来在您的Apache中启用rewrite

sudo a2enmod rewrite

Finally, restart your apache service by this command: 最后,通过以下命令重新启动apache服务:

sudo service apache2 restart

and then check the 'url' helper enabled in autoload.php line no : 67 file in config folder 然后检查“ autourl.php”行中启用的“ url”帮助程序:配置文件夹中的67文件

$autoload['helper'] = array('url');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM