Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.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
.htaccess 为什么我的CodeIgniter项目需要这种调整才能在我的live服务器上工作?_.htaccess_Codeigniter - Fatal编程技术网

.htaccess 为什么我的CodeIgniter项目需要这种调整才能在我的live服务器上工作?

.htaccess 为什么我的CodeIgniter项目需要这种调整才能在我的live服务器上工作?,.htaccess,codeigniter,.htaccess,Codeigniter,我在部署我的站点时遇到问题。我的角度部分收到404错误,但我的index.php模板加载正常。这是我的.htaccess: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/$1 [L] 我在这里找到了解决方案: 在index.php之后添加一个? RewriteEngine on RewriteCond

我在部署我的站点时遇到问题。我的角度部分收到404错误,但我的index.php模板加载正常。这是我的.htaccess:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
我在这里找到了解决方案:

index.php
之后添加一个

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
我对.htaccess有一个基本的了解,但我似乎可以找到一个解释


谢谢。

在第一种情况下,如果没有
,请求的参数保存在
路径信息中

在第二种情况下,对于
,这是最常见的
查询字符串
变量

它们都是超级全局的
$\u服务器的一部分,但它们是由HTTP服务器设置的。这完全取决于Apache/Nginx/Lighttpd/任何配置<代码>路径信息不总是设置的:依赖此变量不安全

但是,当在URL中传递路由时,不使用
,也可以使用
请求URI
读取路由。软件(在您的案例中是框架)需要能够阅读它


具有相同的开发和生产环境非常重要。由于您无法在共享主机环境中更改此配置(而您可以在虚拟或专用服务器上执行您想要的操作),因此您应该首先检查生产配置,然后调整本地配置,以便轻松部署代码。

我认为这与FastCGI有关,我以前多次遇到此问题,因此我开始在默认情况下将问号添加到所有部署中,因为它不会影响其他环境。