删除one.com中codeigniter上的index.php

时间:2014-05-27 09:28:08

标签: php .htaccess codeigniter

这是.htaccess但不起作用

<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /

        #Removes index.php from ExpressionEngine URLs
        RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
        RewriteCond %{REQUEST_URI} !/configSite/.* [NC]
        RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

        RewriteEngine On
        RewriteCond $1 !^(index.php|public|robots.txt)
        RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

配置文件:

$config['uri_protocol'] = 'REQUEST_URI';
$config['index_page'] = '';

我想访问http://serv.er/controller/而不是http://serv.er/index.php/controller/

怎么做?

由于

3 个答案:

答案 0 :(得分:0)

试试这个:

确保您已在Apache模块上启用 rewrite_module

.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

打开config.php: -

$config['index_page'] = '';

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

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

答案 1 :(得分:0)

检查你的php配置是否启用了mod_rewrite 在您的服务器中创建文件info.php包含

    <?php
php_info();
?>

然后运行http://localhost/info.php

您可以在其中检查启用mod_rewrite

答案 2 :(得分:0)

的.htaccess

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

的config.php

$config['base_url'] = 'http://www.one.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

routes.php文件

$route['default_controller'] = "controller";