1

在我打开这篇文章之前,我确实花了三天时间试图弄清楚这一点,但一点运气都没有,所以请帮助我。谢谢~~~~

好的,这就是我到目前为止所做的:

  1. 安装 CI 2.1.3 的新副本,对任何文件夹都没有任何名称更改
  2. 使用我在 Google 上找到的所有结构创建一个新的 .htaccess 文件到 CI ROOT 目录
  3. 将 config['index_page'] 更改为空,例如。配置['index_page'] ='';
  4. 设置 config['uri_protocol'] = 'REQUEST_URI' 或 'QUERY_STRING'</li>
  5. 每次我进行上述更改时,甚至重新启动 MAMP(PHP 5.4)
  6. 已启用:httpd.conf 中的 LoadModule rewrite_module modules/mod_rewrite.so
  7. 在 https.conf 中添加“Options Indexes FollowSymLinks MultiViews”(我唯一不确定)
  8. (我不知道我现在应该尝试什么 V_V )

然后,我得到了这个:

是的工作: http ://ci.dev/index.php/welcome/index

不工作: http ://ci.dev/welcome/index

以下是我现在所拥有的一些细节:

.htaccess 文件:

# I got 500 error if I uncommend this line: <IfModule mod_rewrite.c>
#http://ci.dev/index.php/welcome/index  this is works fine only if the above line commend out
RewriteEngine On
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/?$1 [L]
# I got 500 error if I uncommend this line: </IfModule> 

配置文件

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

主机文件

127.0.0.1 localhost
127.0.0.1 test.dev
127.0.0.1 ci.dev 

httpd.conf 文件

#the following line also enabled
LoadModule rewrite_module modules/mod_rewrite.so  in httpd.conf

...

# The following code I placed at the bottom of https.conf file

NameVirtualHost *

<VirtualHost *>
 ServerName localhost
 DocumentRoot "/Applications/MAMP/htdocs"
</VirtualHost>

<VirtualHost *> 
 ServerName ci.dev
 DocumentRoot /Users/coda/Sites/ci
 <Directory /Users/coda/Sites/ci>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
 </Directory>
</VirtualHost>

<VirtualHost *> 
 ServerName test.dev
 DocumentRoot /Users/coda/Sites/test
</VirtualHost> 

请帮帮我~~~~

谢谢

==================================================== ================

感谢所有在这里尝试帮助我的人。我终于让它工作了,我认为在忽略了一些简单的事情之后,我不知何故把事情复杂化了。

我只是安装了 CI2 的另一个副本,并且只更改了 .htaccess 文件:

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

然后就万事大吉了~!!!!——</p>

4

4 回答 4

3

试试这个 .htaccess (把它放到项目目录的根目录下,即 /chat 这里):

# To remove index.php from URL

RewriteEngine On
# RewriteBase /chat
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

RewriteBase如果您在子目录中有项目,请将其放入,否则将其删除

于 2013-03-12T07:31:23.003 回答
1

在此处输入图像描述

笔记:

htdocs是根文件夹

ci_intro是代码点火器的文件夹

如果我们有同样的情况,那么你的 .htaccess 应该是这样的

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /ci_intro/

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

请注意RewriteBase /ci_intro/将 ci_info 更改为您的 codeigniter 文件夹。

于 2013-03-12T07:23:44.463 回答
1

将 .htaccess 文件与 index.php 文件一起放在应用程序根目录中。(检查 htaccess 扩展是否正确,Bz htaccess.txt 对我不起作用。)

并将以下规则添加到 .htaccess 文件中,

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

然后在您的 application/config/config.php 文件中找到以下行

$config['index_page'] = 'index.php';

将变量设置为空,如下所示。

$config['index_page'] = '';

就是这样,它对我有用。

如果它不起作用,请尝试用这些参数('AUTO'、'PATH_INFO'、'QUERY_STRING'、'REQUEST_URI'和'ORIG_PATH_INFO')一一替换以下变量

$config['uri_protocol'] = 'AUTO';
于 2013-03-12T06:36:47.083 回答
0

试试看 :

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* /codeigniterNameFolder/index.php/$0 [PT,L]

更改 codeigniterNameFolder :)

于 2013-05-07T04:48:14.930 回答