Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从主机服务器上Codeigniter中的url中删除index.php_Php_Codeigniter - Fatal编程技术网

从主机服务器上Codeigniter中的url中删除index.php

从主机服务器上Codeigniter中的url中删除index.php,php,codeigniter,Php,Codeigniter,大家好,我正试图从url中隐藏index.php,就像这样: 我想要:mydomain.com/index.php/mycontroller 类似于:mydomain.com/mycontroller 这是我的.htaccess Options -Multiviews Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /

大家好,我正试图从url中隐藏index.php,就像这样:

我想要:mydomain.com/index.php/mycontroller

类似于:mydomain.com/mycontroller

这是我的.htaccess

Options -Multiviews
Options +FollowSymLinks

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]


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

RewriteCond $1 !^(index\.php|images|robots\.txt|css)

RewriteRule ^(.*)$ index.php?/$1 [L] 
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|static)
RewriteRule ^(.*)$ /index.php/$1 [L]
这是我的conf.php

$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
问题是,它在本地运行良好,但在服务器上运行不好

这是我的文件的处置

- bin
- etc
- mail
- public_ftp
- public_html
 -- application
 -- assets
 -- system
 -- .htaccess
 -- index.php

帮助大家

这是.htaccess的东西

<IfModule mod_rewrite.c>

    Options +FollowSymLinks -Indexes
    RewriteEngine on

    # NOTICE: If you get a 404 play with combinations of the following commented out lines
    #AllowOverride All
    #RewriteBase /

    # Restrict your site to only one domain
    #RewriteCond %{HTTP_HOST} !^www\.
    #RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

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

    <IfModule mod_php5.c>
        RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>

    <IfModule !mod_php5.c>
        RewriteRule ^(.*)$ index.php?/$1 [L]
    </IfModule>

</IfModule>

#prevent access to htaccess file
<Files .htaccess>
 order allow,deny
 deny from all
</Files>

#disable directory browsing
Options All -Indexes
IndexIgnore *

选项+FollowSymLinks-索引
重新启动发动机
#注意:如果你得到一个404播放与以下注释线的组合
#允许超越所有
#重写基/
#将您的站点仅限于一个域
#重写cond%{HTTP_HOST}^www\。
#重写规则^(.*)$http://www.%{HTTP_HOST}/$1[R=301,L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L]
重写规则^(.*)$index.php?/$1[L]
#阻止访问htaccess文件
命令允许,拒绝
全盘否定
#禁用目录浏览
选项所有-索引
IndexIgnore*
在config.php中

  • 将基本URL设置为“”
  • 将$config['index_page']设置为空
  • 字符串集$config['uri\u protocol']='REQUEST\u uri'
  • 我所有的.htaccess

    Options -Multiviews
    Options +FollowSymLinks
    
    RewriteEngine On
    
    RewriteBase /
    
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteCond $1 !^(index\.php|images|robots\.txt|css)
    
    RewriteRule ^(.*)$ index.php?/$1 [L] 
    
    RewriteEngine on
    RewriteCond $1 !^(index\.php|robots\.txt|static)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    

    您应该确保属性
    AllowOverride
    设置正确,例如:
    httpd.conf
    目录段中的
    AllowOverride ALL
    ,在root.htaccess文件中进行以下更改

     RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php/$0 [PT,L]
    
    这对我有用

    $config['base_url']    = 'http://'.$_SERVER['HTTP_HOST'].'/';
     $config['index_page'] = '';
    
    htaccess:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]
    
    如果仍然遇到问题,请尝试更换:

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

    或者其他一些不同的(在config.php中,您可以找到所有可用于尝试uri_协议参数的选项)

    @asmadeahraoui:您能提到您的版本吗?它的codeigniter 2,对于服务器,它的共享主机服务器是php5.4try,现在是@asmadeahraoui