我为我的 API 设置了一个子域api.server.com
。我可以在这里运行我的应用程序,但我想在这个子域的文件夹中运行它,特别是 v1.1 。当我尝试这个时,我得到了404
.
我已经.htaccess
用多条路径修改了我的路径,一直没有高兴地回到根目录。
RewriteEngine On
# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
# RewriteBase /
RewriteBase /all/the/way/back/to/root/www/api/v1/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization},last]
我已经尝试了这里的所有可能性。
/all/the/way/back/to/root/www/api/v1/
/the/way/back/to/root/www/api/v1/
/way/back/to/root/www/api/v1/
/back/to/root/www/api/v1/
/to/root/www/api/v1/
/root/www/api/v1/
/www/api/v1/
/api/v1/
/v1/
但仍然得到 404。有什么建议可以解决这个问题吗?
这是 www/api/v1 的实际 .htaccess
RewriteEngine On
# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
# RewriteBase /
RewriteBase /api/v1/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization},last]
我想用主域作为api网站
运行以下脚本
<?php
//Gets the document root
$root = getenv("DOCUMENT_ROOT") ;
Echo $root;
?>
给我/var/www/domainname.com/web