Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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 在具有子文件夹的同一服务器上安装2个Codeigniter 我有以下情况:_Php_.htaccess_Codeigniter - Fatal编程技术网

Php 在具有子文件夹的同一服务器上安装2个Codeigniter 我有以下情况:

Php 在具有子文件夹的同一服务器上安装2个Codeigniter 我有以下情况:,php,.htaccess,codeigniter,Php,.htaccess,Codeigniter,Codeigniter网站(我们称之为WebA)安装在sebserver“/”的根目录上,可从以下域访问:www.example.com 另一个Codeigniter网站(我们称之为WebB)安装在同一Web服务器的子文件夹“/子文件夹”中,可从以下域访问:www.example2.com 我在WebA和WebB上安装了2个删除index.php的.htacces文件: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /

Codeigniter网站(我们称之为WebA)安装在sebserver“/”的根目录上,可从以下域访问:www.example.com

另一个Codeigniter网站(我们称之为WebB)安装在同一Web服务器的子文件夹“/子文件夹”中,可从以下域访问:www.example2.com

我在WebA和WebB上安装了2个删除index.php的.htacces文件:

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

#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 ^(.*)$ /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]

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (auth|register|secure)
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301]

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !(static|auth|register|secure)
RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301]

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

AddType application/vnd.ms-fontobject .eot
AddType application/octet-stream .otf .ttf
在WebB的/subfolder/application/config/config.php中:

$config['base_url'] = 'http://example.com/';
$config['base_url'] = 'http://example2.com/';
$config['base_url'] = 'http://example.com/';
错误1: 通过此配置,当我访问www.example2.com时,我得到:

404找不到页面

错误2: 如果我将WebB的.htaccess基线更改为:

RewriteBase /subfolder/
我在索引中输出html“http://example2.com/“但它不会加载我的任何JS或CSS,因为它不会加载脚本,而是加载以下内容:

<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  Trying to get property of non-object</p>
<p>Filename: controllers/html.php</p>
<p>Line Number: 60</p>

</div><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Warning</p>
<p>Message:  Cannot modify header information - headers already sent by (output started at /var/www/subfolder/system/core/Exceptions.php:185)</p>
<p>Filename: helpers/url_helper.php</p>
<p>Line Number: 546</p>

</div>
以及WebB在.htaccess中的基线访问:

RewriteBase /subfolder/
当被www.example.com/subfolder/和www.example2.com访问时,它工作正常,但问题是WebB的链接,我需要它们作为www.example2.com而不是www.example.com/subfolder/

WebA一直在工作


我有相同的代码在多个网站上工作,没有任何问题,但我以前从未遇到过这种情况。有什么想法吗?

在安装中使用virtualhosts可以使您免于配置.htaccess的痛苦。

好的,所以我终于做到了,我做了:

我要求我的系统管理员按照建议更改所有网站以使用Virtualhosts,但我不知道他是否做对了,因为我在WebB上仍然有错误:

WebA安装在/var/www/subfolderA中

WebB安装在/var/www/subfolderB中

韦伯 WebA的htaccess文件配置为基线:

RewriteBase /subfolderA/
和config.php:

$config['base_url'] = 'http://example.com/';
$config['base_url'] = 'http://example2.com/';
$config['base_url'] = 'http://example.com/';
韦伯 WebB的htacces文件完全更改为以下4行:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L] 
和config.php,以:

$config['base_url'] = 'http://example.com/subfolder/';
$config['base_url'] = 'http://example2.com/';

我从未使用CI做过这种类型的工作,但我知道CI允许您在同一系统中拥有多个应用程序。我只知道,您可以创建更多具有正确名称的应用程序文件夹,然后配置CI以更正路由。如果您在CI的文档中检查这种类型的尝试,这可能是值得的。我尝试过这种尝试,但我不知道系统管理员是否正确执行了此操作,因为我仍然存在相同的问题,我在/var/www/下创建了2个子文件夹(子文件夹A,子文件夹B),但在子文件夹B下我仍然存在与WebB的配置问题,我将使用我自己的问题来解决我为使其正常工作所做的更改。如果没有管理员的“代码”,我说不出来,我正在将其用于我的博客以及我在/wiki和/blog下的wiki,没有问题。我相信这与启动“一个应用位于另一个应用文件夹”的策略不同。很高兴你解决了这个问题。是的,我做了很多改变,直到我用这个方法工作,谢谢