繁体   English   中英

从Codeigniter .htacceess中删除“ index.php”

[英]Remove “index.php” from Codeigniter .htacceess

我在Codeigniter工作了几天,一切进展顺利,接受我无法终生摆脱URL中的index.php(从localhost / index.php / controller到localhost / controller) )。

我正在使用CI的默认index.php。

在Apache中启用了重写功能。

$config['index_page'] = "";
$config['uri_protocol'] = 'AUTO';

(尽管我尝试了URI的其他四个设置)

.htaccess看起来像这样。

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /

  RewriteCond $1 !^(index\.php|resources|robots\.txt)
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]

  <Files "index.php">
    AcceptPathInfo On
  </Files>
</IfModule>

<IfModule !mod_rewrite.c>
  ErrorDocument 404 /index.php
</IfModule>

我在这里这里都尝试过答案

帮助会很棒

谢谢

附注:如果有问题,我正在子域中工作。

将以下规则放入.htaccess文件,

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

如果以上行不起作用,则需要打开CI配置文件application / config / config.php

在那找到以下行

$config['index_page'] = 'index.php';

更改为:

$config['index_page'] = '';

如果还是不行,请尝试将uri_protocol更改为config中的auto:

$config['uri_protocol'] = 'AUTO';

在.htaccess中,这可能是个问题
RewriteCond $1 !^(indew\\.php|resources|robots\\.txt)
并确保启用了重写模块。 如何为Apache 2.2启用mod_rewrite
或者对于RewriteRule行,尝试将其更改为此

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

(index.php之前的/

暂无
暂无

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

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