子域文件夹中的CodeIgniter,从地址中删除index.php

Mar*_*rko 1 .htaccess codeigniter

因此,我尝试使用本手册从地址中删除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]
Run Code Online (Sandbox Code Playgroud)

但不幸的是它失败了,我得到404错误.我想问题是,我正在尝试在子域文件夹中配置.htaccess,因此它不适合手动,需要一些额外的,但我不知道它需要什么额外的东西.

cwa*_*ole 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>
Run Code Online (Sandbox Code Playgroud)