如何从别名域击中编码器API ?



我在www.mysiteone.com/project的condeigniter 3中构建了一个REST API项目,它工作得很好。现在,我的另一个域是www.mysitetwo.com/project,它被配置成这样,它会命中第一个url。例如,如果我浏览www.mysitetwo.com/project/license.txt,它会显示www.mysiteone.com/project/license.txt中应有的文件。但问题是,当我试图访问任何api。像www.mysiteone.com/project/apiendpoint返回数据,但当我点击www.mysitetwo.com/project/apiendpoint时,它显示以下错误:

<html>
<head>
<title>404 Not Found</title>
</head>
<body>
<h1>Not Found</h1>
<p>The requested URL /srv/www/mysiteone.com/www/project/index.php/apiendpoint was not found on this server.
</p>
</body>
</html>

这里是项目文件夹

中的。htaccess文件
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

在config.php

$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

我应该在哪里进行更改以使此工作?

需要替换

RewriteRule ^(.*)$ index.php/$1 [L]

RewriteRule ^(.*)$ /project/index.php/$1 [L]

下面将更有效地处理未来可能出现的情况。

RewriteEngine on
RewriteCond "%{HTTP_HOST}"    "!^www.mysitetwo.com" [NC]
RewriteCond "%{HTTP_HOST}"    "!^$"
RewriteRule "^/?(.*)"         "http://www.mysiteone.com/$1" [L,R,NE]

最新更新