【发布时间】:2019-11-19 15:17:05
【问题描述】:
我在 linux apache 托管 angular 前端和 php slim 应用程序框架后端进行部署。
在 localhost 中,我在 xampp apache php 中有 localhost:4200 angular 和 localhost:80
路径有效
现在我有 www.mydomain.org/ .(所有部署的角度) .(.htaccess) .folder (slimapp)*php
在我的文件夹内:
- 公开
- index.php
- 源
- 配置
- db.php
- 路线
- event.php,login.php,user.php
- 配置
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html
# to allow html5 state links
RewriteRule ^ index.html [L]
index.php
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, DELETE, PUT, PATCH, OPTIONS');
header('Access-Control-Allow-Headers: token, Content-Type');
require_once '../vendor/autoload.php';
require_once '../slimapp/src/config/db.php';
// 客户路线
$app = new \Slim\App;
require_once "../slimapp/src/routes/user.php";
require_once "../slimapp/src/routes/login.php";
require_once "../slimapp/src/routes/event.php";
$app->run();
我的问题是,我无法理解如何将所有路径链接在一起。
因为 Angular,需要 .htaccess 导致刷新页面我尝试了各种不同的方式但只能工作,所以我需要 index.html
但现在可以刷新但我不能使用 php 后端。
如何使用它,我需要编辑 .htaccess,其中 index.php 必须在路径上?
考虑到例如 api rest : slimapp/event 在我的电脑中,这要归功于 apache 设置和文件主机 localhost/slimapp/public/index.html/event(是从 db 检索事件的 get 调用)
如何需要新路径?在真实域中?
【问题讨论】:
标签: php angular apache .htaccess