【问题标题】:Codeigniter 2 shared hosting sub-directory installationCodeigniter 2 共享主机子目录安装
【发布时间】:2014-10-29 13:13:05
【问题描述】:

我知道这个问题已经被问过很多次了,但我确实搜索了很多,但没有找到答案。所以我希望有人能帮助我。我有一个共享主机,并且我希望在 public_html 文件夹中安装我的 CI 应用程序。子目录名称为“hrms”。

所以我将所有 CI 文件上传到 hrms。现在,当我访问http://www.example.com/hrms/index.php/login/do_login 时,我得到了著名的错误No input file specified. 我已经尝试使用 .htaccess 文件,其中有几个我可以找到的变体,但没有一个有帮助。 http://www.example.com/hrms/index.php 工作正常,所以我猜所有配置都正常。

我做错了什么?另外,.htaccess 文件是否必须,即使我打算通过完整 URL 访问该站点?

==== .htaccess =====

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /hrms

    #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 ^(.*)$ /hrms/index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /hrms/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 ^(.*)$ /hrms/index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

【问题讨论】:

  • 你是否在 index.php 之前的 htaccess 中包含了你的目录名...
  • 我猜不是。你能给我指出一个适合我的好示例 .htaccess 吗?
  • 你能不能把你的帽子密码给我修改一下
  • @Amir Done,请检查。
  • 您是否更改了您的$config['base_url']?我删除了我的答案,因为你的答案是正确的

标签: .htaccess codeigniter codeigniter-2


【解决方案1】:

无事生非。

===== 更新 =====

我现在发现问题出在 GoDaddy 托管上(GoDaddy 和 CI 似乎是又恨又恨的关系)。诀窍是将您的 index.php 定义为 index.php? (注意问号)在 config.php 文件中。

不过,非常感谢所有为此付出努力的人!

请注意:如果您可以接受像 http://www.example.com/index.php?/HomeController/myFunction 这样的丑陋 URL 并且不使用路由(现在像我一样),则不需要 .htaccess 文件。 p>

【讨论】:

  • 真的,我为所有的努力感到谦卑。希望我以后能继续得到这样的支持。 :)
  • 没问题。如果它是基于 CodeIgniter 的,如果你给我加标签,我会一直给它看 :) (虽然没有关于速度的承诺......)
  • 太棒了!非常感谢。 :D
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-14
  • 1970-01-01
  • 2018-04-04
  • 1970-01-01
  • 2015-01-16
  • 1970-01-01
相关资源
最近更新 更多