如何在XAMPP上使用Codeigniter删除index.php?

时间:2010-03-31 10:45:47

标签: .htaccess codeigniter indexing routes xampp

我无法在XAMPP 1.7.3上隐藏Codeigniter index.php

URL:

http://localhost/Servidor/agentesRainbow/index.php/agentes/tony

tony 是一个参数

我的实际.htaccess:

   <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /Servidor/agentesRainbow/

        #'system' can be replaced if you have renamed your system folder.
        RewriteCond %{REQUEST_URI} ^system.*
        RewriteRule ^(.*)$ /Servidor/agentesRainbow/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

        #This last condition enables access to the images and css folders, and the robots.txt file
       RewriteCond $1 !^(index\.php|images|css|public|)
       RewriteRule ^(.*)$ /Servidor/agentesRainbow/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.
        ErrorDocument 404 /application/errors/404.php
    </IfModule>

我的routes.php:

$route['agentes/(:any)'] = "agentes/index/$1";

$route['default_controller'] = "agentes";
$route['scaffolding_trigger'] = "";

我的config.php:

$config['base_url'] = "http://localhost/Servidor/agentesRainbow/";
$config['index_page'] = "";
$config['uri_protocol'] = "AUTO";

在httpd.conf上:

LoadModule rewrite_module modules/mod_rewrite.so

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

<Directory /Servidor/agentesRainbow/>
         Options FollowSymLinks
         AllowOverride All
         Order deny,allow
         Deny from all
</Directory>

3 个答案:

答案 0 :(得分:7)

将此行添加到REQUEST_FILENAME条件:

RewriteRule ^(.*)$ /Servidor/agentesRainbow/index.php/$1 [L]

这是更新的.htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /Servidor/agentesRainbow/

    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /Servidor/agentesRainbow/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 ^(.*)$ /Servidor/agentesRainbow/index.php/$1 [L]

    #This last condition enables access to the images and css folders, and the robots.txt file
    RewriteCond $1 !^(index\.php|images|css|public)
    RewriteRule ^(.*)$ /Servidor/agentesRainbow/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.
    ErrorDocument 404 /application/errors/404.php
</IfModule>

希望它能解决你的问题!

答案 1 :(得分:2)

我认为重写条件结束时的栏会导致问题。至少它打破了我的重写。

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

尝试删除栏。

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

答案 2 :(得分:0)

base_url应该只是“http://localhost”;

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|other|directories|you|want|accessible|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>