如何去除codeigniterpath中的“index.php”
如何删除中间某个位置的codeigniter中的每个path中的"index.php" ? 我想干净的非index.php-fied URLs ? 
如果您使用Apache,将.htaccess文件放在您的根网站目录中,其中包含以下内容:
 RewriteEngine on RewriteCond $1 !^(index\.php|[Javascript / CSS / Image root Folder name(s)]|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] 
另一个好的版本位于这里:
我有删除index.php一些大问题。 一般来说,下面的.htaccess已经在几台服务器上进行了testing,
 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] <Files "index.php"> AcceptPathInfo On </Files> 
如果你没有任何运气,那么下一步就是调整你的configuration文件。 尝试一些其他的URI协议,例如
 | 'AUTO' Default - auto detects | 'PATH_INFO' Uses the PATH_INFO | 'QUERY_STRING' Uses the QUERY_STRING | 'REQUEST_URI' Uses the REQUEST_URI | 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO $config['uri_protocol'] = 'ORIG_PATH_INFO'; 
如果你还没有任何运气尝试改变重写规则,以包括您的子文件夹。 如果您在开发者服务器上使用临时URL,这通常是一个问题:
 RewriteRule ^(.*)$ /subofolder1/subfolder2/index.php/$1 [L] 
只要玩这些选项,一个应该工作。 另外,请确保您的索引文件设置为:
 $config['index_page'] = ''; 
祝你好运!
在应用程序根目录中有.htaccess文件以及index.php文件。 (检查htaccess扩展是否正确,Bz htaccess.txt不适用于我。)
并将以下规则添加到.htaccess文件中,
 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] 
然后在application / config / config.php文件中find以下行
 $config['index_page'] = 'index.php'; 
如下设置variables为空。
 $config['index_page'] = ''; 
就是这样,它为我工作。
如果不能继续工作,请尝试用这些参数(“AUTO”,“PATH_INFO”,“QUERY_STRING”,“REQUEST_URI”和“ORIG_PATH_INFO”)逐个replace以下variables
 $config['uri_protocol'] = 'AUTO'; 
 看一下system\application\config\config.php文件,有一个名为index_page的variables 
它应该看起来像这样
 $config['index_page'] = "index.php"; 
改变它
 $config['index_page'] = ""; 
 然后如前所述,您还需要将重写规则添加到.htaccess文件 
 注意:在CodeIgniter v2中,这个文件被移出了系统文件夹到application\config\config.php 
以上所有方法失败,然后我发现我没有更改AllowOverride无以AllowOverride所有在我的虚拟主机文件在/ etc / apache2 / sites-available / default
 <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride All <---- replace None with All </Directory> <Directory /var/www > Options Indexes FollowSymLinks MultiViews AllowOverride All <--- replace None with All Order allow,deny allow from all </Directory> ... 
 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* /codeigniter/index.php/$0 [PT,L] 
在改变RewriteRule。* index.php / $ 0 [PT,L]与项目文件夹名称“codeigniter”。为我工作。 谢谢你们的支持。
只是想我可以补充
 RewriteEngine on RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
将是.htaccess,并确保以下列方式编辑您的application / config.phpvariables:
更换
 $config['uri_protocol'] = “AUTO” 
同
 $config['uri_protocol'] = “REQUEST_URI” 
 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [PT,L] 
这一定是肯定的工作..有一个尝试
步骤1 =>将.htaccess文件放在应用程序和系统文件夹所在的根文件夹中。
步骤2 =>如果您的networkingpath使用子文件夹 – yourdomain.com/project/ – 然后在htaccess文件中使用以下代码
 RewriteEngine on RewriteBase /project/ RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /project/index.php/$1 [L] 
如果您的networkingpath使用根文件夹 – yourdomain.com – 然后在htaccess文件中使用以下代码
 RewriteEngine on RewriteBase / RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] 
完美的解决scheme[在本地主机以及真实域上testing]
 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [PT,L] 
这是我的一个CI项目的一个.htaccess:
 RewriteEngine on RewriteCond $1 !^(index\.php|images|css|js|robots\.txt) RewriteRule ^(.*)$ /projectFolder/index.php/$1 [L] 
最后一行应该给你你所需要的,尽pipe你可能或不需要'/ projectFolder'取决于你的文件夹结构的设置。 祝你好运!
 使用mod_rewrite按照本教程中的指导从CI维基。 
 确保你已经启用mod_rewrite (我没有)。 
 启用: 
 sudo a2enmod rewrite 
 另外,通过AllowOverride AllreplaceAllowOverride None 
 sudo gedit /etc/apache2/sites-available/default 
Finaly …
 sudo /etc/init.d/apache2 restart 
我的.htaccess是
 RewriteEngine on RewriteCond $1 !^(index\.php|[assets/css/js/img]|robots\.txt) RewriteRule ^(.*)$ index.php/$1 [L] 
 查看\application\config\config.php文件,有一个名为index_page的variables 
它应该看起来像这样
 $config['index_page'] = "index.php"; 
改变它
 $config['index_page'] = ""; 
 然后如上所述,您还需要像下面这样将重写规则添加到.htaccess文件中: 
 RewriteEngine on RewriteCond $1 !^(index\\.php|resources|robots\\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
它为我工作,也希望你。
作为一个.htaccess文件,一个好的select是使用Kohana框架提供的一个:
 # Turn on URL rewriting RewriteEngine On # Installation directory RewriteBase / # Protect hidden files from being viewed <Files .*> Order Deny,Allow Deny From All </Files> # Protect application and system files from being viewed RewriteRule ^(?:application|system)\b.* index.php/$0 [L] # Allow any files or directories that exist to be displayed directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Rewrite all other URLs to index.php/URL RewriteRule .* index.php/$0 [PT] 
这是一个深思熟虑的.htaccess只是工作。
我在许多不同的托pipeapache2上testing这个,它工作的很好。
使用这个htaccess
 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/$1 [L] 
 确保你已经enabled mod_rewirte phpinfo(); 
然后在config / config.php中执行此操作:
 $config['index_url'] = ''; | | 'AUTO' Default - auto detects | 'PATH_INFO' Uses the PATH_INFO | 'QUERY_STRING' Uses the QUERY_STRING | 'REQUEST_URI' Uses the REQUEST_URI | 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO | */ $config['uri_protocol'] = 'AUTO'; 
 如果还没有正常工作,请尝试将$config['uri_protocol']='AUTO'更改为$config['uri_protocol']='AUTO'行中列出的application/config/config.php文件之一: 
 有时我使用: REQUEST_URI而不是AUTO或"QUERY_STRING"为goDaddy托pipe 
如果你在Linux上并使用apache2服务器,那么我们可能需要覆盖.htaccess文件上更改旁边的apache2.conf文件。 在/etc/apache2/apache2.conf上findapache2configuration文件。
search目录/ var / www /更改AllowOverride无 – > AllowOverride全部
 <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory 
有两种方法可以解决codeigniter的urlpath中的index.php问题
1:在config / config.php中更改代码:
 $config['index_page'] = 'index.php'; 
至
 $config['index_page'] = ''; 
2:如果未创build,在根path中创build.htacess,复制以下代码: –
 <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] </IfModule> 
保存它,然后检查你的Apacheconfigurationrewrite_module或mod_rewrite是启用。如果不是,那么请启用。 (最佳方法)!
将一个.htaccess文件放到你的根目录下
无论你怎么调整 – 如果上述不符合,它将无法工作。 通常它在System文件夹中,它应该在根目录下。 干杯!
我已经尝试了很多解决scheme,但是我想到的是这样的:
 DirectoryIndex index.php RewriteEngine on RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|jquery|js|robots \.txt|favicon\.ico) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ ./index.php?$1 [L,QSA] 
这将根据需要从url中删除index.php。
这将帮助您将此代码粘贴到.htacess文件中的应用程序文件夹中
 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] <Files "index.php"> AcceptPathInfo On </Files> <IfModule mod_php5.c> php_value short_open_tag 1 </IfModule> 
 我在.htaccess文件中使用这些行; 我把它放在根文件夹中 
 RewriteEngine on RewriteRule ^(application|system|\.svn) index.php/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [QSA,L] 
然后我可以访问http://example.com/controller/function/parameter
而不是http://example.com/index.php/controller/function/parameter
这一个完成了我的魔法:
 RewriteEngine on RewriteBase / # Hide the application and system directories by redirecting the request to index.php RewriteRule ^(application|system|\.svn) index.php/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [QSA,L] 
希望它有帮助!
嗨这一个工作我
 RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /folder/index.php?/$1 [L] 
以及这个
 RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /folder/index.php?/$1 [L] 
如果该codeigniter应用程序作为子域名托pipe,例如domainname / folder / index.php,则该文件夹是子文件夹的名称。
希望这对你有用。 谢谢。
在.htaccess中复制以下代码
 RewriteEngine on Options -Indexes RewriteCond $1 !^(index\.php|assets|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA]