CodeIgniter - 如何从URL隐藏index.php

时间:2023-01-13 11:19:23

This is what my .htaccess looks like. The .htaccess is sitting in /www/scripts directory which is the parent of codeigniter's system directory and which also contains index.php. I have enabled mod_rewrite in my Apache 2.2.x. This is on Ubuntu 9.10 server.

这就是我的.htaccess的样子。 .htaccess位于/ www / scripts目录中,该目录是codeigniter系统目录的父目录,也包含index.php。我在Apache 2.2.x中启用了mod_rewrite。这是在Ubuntu 9.10服务器上。

I followed this link, but it does not work. Is there anything I need to do in apache2, any specific configuration so that this works?

我按照这个链接,但它不起作用。我在apache2中有什么需要做的,任何特定的配置都可以这样做吗?

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

5 个解决方案

#1


8  

use this:

用这个:

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

#2


3  

Just toss the following code into your .htaccess file

只需将以下代码放入.htaccess文件即可

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Source: http://codeigniter.com/user_guide/general/urls.html

资料来源:http://codeigniter.com/user_guide/general/urls.html

#3


2  

Try these links, it may help your question:
http://ellislab.com/forums/viewthread/153950/
http://ellislab.com/forums/viewthread/153372/

试试这些链接,它可能有助于您的问题:http://ellislab.com/forums/viewthread/153950/ http://ellislab.com/forums/viewthread/153372/

#4


0  

here is the solution simply drop in root.

这里的解决方案只是简单地放入root。

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L] 

#5


-2  

CodeIgniter User Guide on URLs

关于URL的CodeIgniter用户指南

#1


8  

use this:

用这个:

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

#2


3  

Just toss the following code into your .htaccess file

只需将以下代码放入.htaccess文件即可

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Source: http://codeigniter.com/user_guide/general/urls.html

资料来源:http://codeigniter.com/user_guide/general/urls.html

#3


2  

Try these links, it may help your question:
http://ellislab.com/forums/viewthread/153950/
http://ellislab.com/forums/viewthread/153372/

试试这些链接,它可能有助于您的问题:http://ellislab.com/forums/viewthread/153950/ http://ellislab.com/forums/viewthread/153372/

#4


0  

here is the solution simply drop in root.

这里的解决方案只是简单地放入root。

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L] 

#5


-2  

CodeIgniter User Guide on URLs

关于URL的CodeIgniter用户指南