codeIgniter子域文件夹,删除从地址的index.php文件夹、地址、codeIgniter、index

2023-09-02 00:46:21 作者:梦望断。

所以,我想使用本手册从地址中删除的index.php: HTTP ://dev.lohv.eu/1/user_guide/general/urls.html

So I am trying to remove index.php from address using this manual: 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文件:

I created .htaccess file according to manual:

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

但unfortunaly失败,我得到404错误。我想这个问题是,我想配置的.htaccess子域文件夹,这样它不会适合作为人工,需要一些额外的,但我不知道是什么群众演员需要。

But unfortunaly it fails, I get 404 error. I guess the problem is, I am trying to configure .htaccess in subdomain folder so it wont fit as in manual and needs some extra, but I don't know what extras it needs.

推荐答案

我觉得你错过了一个?。 重写规则^(。*)$ /index.php?/$1 [L]

I think you're missing a '?'. RewriteRule ^(.*)$ /index.php?/$1 [L]

这是CI推荐的.htaccess模板(或者至少是一年前),而两者之间的主要区别。

This is CI's recommended .htaccess template (or at least it was a year ago), and that ? is the major difference between the two.

<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>