繁体   English   中英

htaccess在Codeigniter中不起作用

[英]Htaccess not working in Codeigniter

我在我的项目中使用tank auth。 在我的本地主机,它工作正常。 但是,当我将项目上传到服务器时,出现以下错误:

未指定输入文件。

我知道这是因为htaccess。 我的网址就像http://example.org/project/test/tankauth/ 当我提供此网址时,它将重定向到http://example.org/project/test/tankauth/index.php/auth/login并显示错误。 但是,如果我尝试使用类似http://example.org/project/test/tankauth/index.php?/auth/login的网址,它将可以正常工作。

我的htaccess文件如下所示:

RewriteEngine on
RewriteBase /tankauth/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

我的htaccess不好。

我假设您在此服务器上使用apache,我还假设您尚未对apache config / etc / apache2 /进行任何更改,最后我假设您可以访问服务器,那么如果在这种情况下,您可能要检查http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride

在您的/ etc / apache2 / sites-available / default中,您会找到

<Directory /path/to/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None <---change None to FileInfo or All
Order allow, deny
allow from all
</Directory>

然后重置您的apache-> service apache2 restart or sudo service apache2 restart

抬起头使用AllowOverride All可以标记一些严重的漏洞问题,如果这是一个生产服务器,我建议你不要使用它。

希望能有所帮助,加油!

试试这个(更改最后一行)

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

并在application / config / config.php中

$config['uri_protocol']         ="PATH_INFO";

是工作。

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /tankauth/
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(.*)$ index.php/$1[L]
</IfModule>

暂无
暂无

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

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