【问题标题】:CodeIgniter in subdomain folder, removing the index.php from address子域文件夹中的 CodeIgniter,从地址中删除 index.php
【发布时间】:2011-06-22 22:57:55
【问题描述】:

所以我正在尝试使用本手册从地址中删除 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,因此它不会像手动那样适合并且需要一些额外的东西,但我不知道它需要什么额外的东西。

【问题讨论】:

    标签: .htaccess codeigniter


    【解决方案1】:

    我认为您缺少一个“?”。 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>
    

    【讨论】:

      猜你喜欢
      • 2017-01-19
      • 2016-01-16
      • 1970-01-01
      • 2019-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-01
      相关资源
      最近更新 更多