【问题标题】:How can I remove index.php using Codeigniter on XAMPP?如何在 XAMPP 上使用 Codeigniter 删除 index.php?
【发布时间】:2011-02-02 21:00:54
【问题描述】:

我无法在 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>

我的路线.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>

【问题讨论】:

    标签: .htaccess codeigniter indexing routes xampp


    【解决方案1】:

    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>
    

    【讨论】:

      【解决方案2】:

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

      希望它能解决你的问题!

      【讨论】:

        【解决方案3】:

        我认为重写条件末尾的栏引起了问题。至少它打破了对我的重写。

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

        尝试删除栏。

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

        【讨论】:

        • 他甚至不需要该行,因为上面的两个条件会对其进行排序。
        猜你喜欢
        • 2017-04-04
        • 1970-01-01
        • 1970-01-01
        • 2021-04-11
        • 2021-12-15
        • 2012-03-26
        • 2012-09-22
        • 2011-01-18
        • 1970-01-01
        相关资源
        最近更新 更多