2

我是 Codeigniter 的新手,我在 codeigniter 2.1.3 的根文件夹中放了一个 .htaccess。我已经在 xampp 和 wamp 服务器上尝试了我的 .htaccess 文件,但这并没有删除我的 index.php。我也设置了

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

 $config['index_page'] = '';

这是我的 .htaccess 代码

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond $1 !^(index\.php|js|images|system\/plugins|robots\.txt|css\/)
  RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule> 

我不知道为什么这不会从 url 中删除我的 index.php 页面。帮我!!

4

4 回答 4

4

打开 config.php 确保更改 $config['uri_protocol']= 'REQUEST_URI';

并将此代码放在 .htaccess 文件中

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond $1 !^(index\.php|indexcp\.php?|resources|robots\.txt)
RewriteRule ^([A-Za-z0-9_/.-]+)$ index.php?/welcome/$1 

这就是它对我有用的全部。如果您仍然面临任何问题,请告诉我。

于 2012-12-27T05:33:10.940 回答
1

检查rewrite_module是否配置为on

并尝试从您的代码中删除条件:

RewriteEngine on
RewriteCond $1 !^(index\.php|js|images|system\/plugins|robots\.txt|css\/)
RewriteRule ^(.*)$ index.php/$1 [L]
于 2012-12-27T06:22:57.107 回答
0

我在我的项目中使用了这段代码,它对我有用,

.htaccess :-

<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

config.php :-

$config['index_page'] = '';

$config['base_url'] = 'http://www.example.com/';

我希望这能帮到您

于 2012-12-27T06:14:49.540 回答
0

另一个可以解决的愚蠢问题是包含应用程序的文件夹不是 755。

为了更确定问题是什么,请查看 linux /var/log/apache/error.log 中的 apache 日志文件

于 2017-02-16T12:23:00.897 回答