Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Codeigniter:从本地主机到Web服务器_Php_Apache_Codeigniter_Mod Rewrite_Web - Fatal编程技术网

Php Codeigniter:从本地主机到Web服务器

Php Codeigniter:从本地主机到Web服务器,php,apache,codeigniter,mod-rewrite,web,Php,Apache,Codeigniter,Mod Rewrite,Web,大家好。我正绝望地试图让codeigniter在Web服务器上运行。apache mod_重写已启用,我几乎尝试了在internet上找到的所有相关内容,但没有任何效果 Web服务器上的目录为 cgi bin文件夹已经存在。我读过的帖子说,cgi bin文件夹与此无关。 但这里有第一个问题:这对我来说也是吗?我应该使用哪个.htaccess文件?为什么要放一个.htaccess文件 它们似乎都不起作用: 我尝试了几种设置,最后得到了两个.htaccess文件的以下版本: <IfModul

大家好。我正绝望地试图让codeigniter在Web服务器上运行。apache mod_重写已启用,我几乎尝试了在internet上找到的所有相关内容,但没有任何效果

Web服务器上的目录为

cgi bin文件夹已经存在。我读过的帖子说,cgi bin文件夹与此无关。 但这里有第一个问题:这对我来说也是吗?我应该使用哪个.htaccess文件?为什么要放一个.htaccess文件

它们似乎都不起作用: 我尝试了几种设置,最后得到了两个.htaccess文件的以下版本:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test94252.test-account.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /test94252.test-account.com/index.htm [L]
</IfModule>

重新启动发动机
RewriteBase/test94252.test-account.com
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$/test94252.test-account.com/index.htm[L]
我的目标很简单,如果我调用的域是/website/application/views/index.php。 这个.htaccess文件有什么问题

编辑:在我的本地机器上,我调用index.php文件

请注意:为了测试,我在/website/中放了一个index.htm来检查重定向是否完成,但它不起作用

我期待着您的来信。

首先:

不,你应该安全地删除它
cgi-bin
历史上是唯一可以存储可执行代码或脚本代码(二进制文件、shell脚本等)的地方。它主要是一个历史遗迹,因为大多数主机允许从任何地方执行脚本

当一个.htaccess文件被放置在一个目录中,而该目录又“通过Apache Web服务器加载”时,Apache Web服务器软件会检测并执行该.htaccess文件。
.htaccess
可以是内容密码保护或图像热链接预防

秒:

您应该在
/website
文件夹中编辑
.htaccess

和:

我的文件
.htaccess
在服务器中运行,如下所示:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
</IfModule>
  • 使用下面的代码在根目录中创建
    .htaccess
    文件

    RewriteEngine on
    RewriteCond $1 !^(index\.php|resources|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]
    

  • 注意:删除

    谢谢vanloc,因此如果我理解这一点,我可以使用任何.htaccess文件,因为它不在乎它位于何处。但它仍然不起作用。当我查看您的文件时,它部分类似于。但是我不明白我将如何告诉apace在哪里可以找到/application/views/index.phpIt指向/index.htm,就像没有任何.htaccess文件一样谢谢您的努力。我检查并更新了config中的所有值,并删除了标记。但仍然无效,这意味着/index.htm已加载。请尝试签入
    application/config/routes.php
    。请在以下行发布您的
    $route['default\u controller']
    应用程序/config/config.php
    的值:
    $config['base\u url']
    $route['default\u controller']='pages/view';到目前为止,我从未想过默认的\u controller.Hi,文件夹“website”是否位于public\u html文件夹中?
    RewriteEngine on
    RewriteCond $1 !^(index\.php|resources|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]