简体   繁体   English

CodeIgniter - 如何从URL隐藏index.php

[英]CodeIgniter - How to hide index.php from the URL

This is what my .htaccess looks like. 这就是我的.htaccess样子。 The .htaccess is sitting in /www/scripts directory which is the parent of codeigniter's system directory and which also contains index.php . .htaccess位于/www/scripts目录中,该目录是codeigniter system目录的父目录,也包含index.php I have enabled mod_rewrite in my Apache 2.2.x. 我在Apache 2.2.x中启用了mod_rewrite This is on Ubuntu 9.10 server. 这是在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]

use this: 用这个:

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

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

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] 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM