【问题标题】:remove index.php on codeigniter in one.com在 one.com 中的 codeigniter 上删除 index.php
【发布时间】:2014-05-27 09:28:07
【问题描述】:

这是 .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/

它是怎么做的?

谢谢

【问题讨论】:

  • one.Com 不支持 RewriteBase
  • 我和他们交谈,他们说他们支持并且在 localhost 中不起作用
  • 检查 mod_rewrite 是否启用
  • 在服务器和本地启用
  • @Esloop 奇怪我的解决方案应该可以工作

标签: php .htaccess codeigniter


【解决方案1】:

试试这个:

确保您已在 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';

【讨论】:

  • @Esloop mod_rewrite 已启用?
  • 我现在和他们交谈,他们说他们支持
【解决方案2】:

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

    <?php
php_info();
?>

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

你可以在哪里检查 mod_rewrite 是否启用

【讨论】:

  • 在本地主机上没问题,但在服务器上不行,但我跟他们说他们支持
【解决方案3】:

.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";

【讨论】:

    猜你喜欢
    • 2012-09-30
    • 2016-07-05
    • 2016-05-17
    • 1970-01-01
    • 1970-01-01
    • 2011-10-28
    • 2011-07-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多