使用htaccess删除index.php无效

使用htaccess删除index.php无效,php,apache,.htaccess,codeigniter,Php,Apache,.htaccess,Codeigniter,我想使用根目录中的.htaccess文件删除index.php 我的框架是codeigniter 我的访问权限: AddType application/x-httpd-php53 php53 php php_flag log_errors on php_flag display_errors on #php_value error_reporting 8 php_value error_reporting E_ALL <IfModule mod_rewrite.c> Re

我想使用根目录中的
.htaccess
文件删除
index.php

我的框架是codeigniter

我的访问权限:

AddType application/x-httpd-php53 php53 php

php_flag  log_errors on
php_flag  display_errors on
#php_value error_reporting 8
php_value error_reporting E_ALL

<IfModule mod_rewrite.c>

RewriteEngine on
RewriteCond %{HTTP_HOST} ^megarooz.com/$ [NC]
RewriteRule ^(.*)$ http://megarooz.com/$1 [R=301,L]

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

order allow,deny
allow from all
我得到了这个信息:

Not Found
The requested document was not found on this server. 
它不起作用:

它工作得很好:


尝试使用下面的代码

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L] // you have added / before index.php
    </IfModule>

重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L]//您在index.php之前添加了/

尝试使用下面的代码

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L] // you have added / before index.php
    </IfModule>

重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L]//您在index.php之前添加了/
像这样试试

1.在您的根文件夹中
.htaccess
文件

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
2.在
application/config/config.php中设置以下内容

$config['base_url'] = 'http://megarooz.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
希望它能起作用。

像这样试试

1.在您的根文件夹中
.htaccess
文件

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
2.在
application/config/config.php中设置以下内容

$config['base_url'] = 'http://megarooz.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

希望它能起作用。

因为这是一个在堆栈上非常常见的问题,我希望您下次进行更多的研究,因为它充满了CI的index.php问题。尽管如此,我还是同意CI的htaccess有点糟糕,因为它也不总是对我有效,我最终做的是从Laravel手中抢走htaccess

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

从来没有遇到过问题,希望这能奏效。

因为这是一个非常常见的堆栈问题,我希望您下次进行更多的研究,因为它充满了CI的index.php问题。尽管如此,我还是同意CI的htaccess有点糟糕,因为它也不总是对我有效,我最终做的是从Laravel手中抢走htaccess

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

从未遇到过问题,希望这能起作用。

Apache中是否安装并启用了mod_rewrite?另外,尝试将
上的
更改为
上的
可能重复的@Magnus Eriksson我如何才能看到
模块重写
是否启用?您使用的是什么操作系统?顺便说一句,你使用的是PHP5.3吗?你真的应该升级你的系统。5.3已经很久没有得到支持了。甚至5.6也已经达到了主动支持的极限。我的php版本是
5.5.38
是否在Apache中安装并启用了mod_rewrite?另外,尝试将
上的
更改为
上的
可能重复的@Magnus Eriksson我如何才能看到
模块重写
是否启用?您使用的是什么操作系统?顺便说一句,你使用的是PHP5.3吗?你真的应该升级你的系统。5.3已经很久没有得到支持了。甚至5.6也已经达到了主动支持的极限。我的php版本是
5.5.38