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

标签 .htaccess codeigniter indexing routes xampp

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

网址:

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>

最佳答案

将此行添加到 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>

希望能解决您的问题!

关于.htaccess - 如何在 XAMPP 上使用 Codeigniter 删除 index.php?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2552166/

相关文章:

.htaccess - 带 Codeigniter htaccess 的 SSL

angularjs - "base href"使用 ui-router 在路由 url 中添加目录路径

php - 我的 codeigniter 验证码未生成图像

android - 基于事件应用程序的日期时间实现类似 twitter 的时间线查询

php - CodeIgniter Datalink 与 MySQL 和 MSSQL

mysql - 如何优化对大量行使用分组依据的查询

mysql - 优化 MySQL 数据库索引 InnoDB

.htaccess - HTML5 <audio> 标签在 IE10 中无法工作/播放

python - 使用 numpy 查找每列的最大值及其索引(+ 当最大值在同一列中重复时)

php - RewriteEngine 不在本地重写 URL?