2010-03-31 24 views
2

我不能隱藏在XAMPP笨的index.php 1.7.3如何在XAMPP上使用Codeigniter刪除index.php?

網址:

http://localhost/Servidor/agentesRainbow/index.php/agentes/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> 

回答

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> 

希望它可以解決您的問題!

2

我認爲重寫條件結束時出現問題。至少它打破了我的重寫。

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

嘗試刪除欄。

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

他甚至不需要這條線,因爲它上面的兩個條件將它排序。 – 2010-03-31 11:57:31

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>