所以我尝试使用本手册从地址中删除index.php:http://dev.lohv.eu/1/user_guide/general/urls.html
Atm我有地址http://dev.lohv.eu/1/index.php,但我想在将来使用它而不使用index.php,如下所示:http://dev.lohv.eu/1/
我根据手册创建了.htaccess文件:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
但不幸的是它失败了,我得到404错误。我想问题是,我正在尝试在子域文件夹中配置.htaccess,因此它不适合手动,需要一些额外的,但我不知道它需要什么额外的。
答案 0 :(得分:5)
我觉得你错过了'?'。 RewriteRule ^(.*)$ /index.php?/$1 [L]
这是CI推荐的.htaccess模板(或者至少是一年前),?
是两者之间的主要区别。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /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 ^(.*)$ index.php?/$1 [L]
</IfModule>