0

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

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

就像:mydomain.com/mycontroler

这是我的 .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] 

这是我的 conf.php

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

问题是它在本地运行良好,但在服务器上却不行

这是我的文件的处置

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

帮助伙计们

4

4 回答 4

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

访问:

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_protocol 参数的选项)

于 2013-08-14T12:51:18.007 回答
0

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

在 config.php

  1. 设置基本 URL,如“ http://www.example.com/
  2. 将 $config['index_page'] 设置为空
  3. 字符串设置 $config['uri_protocol'] = 'REQUEST_URI'
于 2013-08-14T04:18:35.217 回答
0

在根 .htaccess 文件中进行以下更改

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

它对我有用。

于 2013-08-14T06:34:28.143 回答
0

我所有的 .htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|static)
RewriteRule ^(.*)$ /index.php/$1 [L]

并且您应该确保该属性AllowOverride设置正确,例如:AllowOverride ALL在您的httpd.conf目录段中

于 2013-08-14T04:42:53.030 回答