php - api路由在子域上上传时在laravel中不起作用?
问题描述
我想在我的子域上上传我的 laravel 应用程序并将其用作 restapi 但是当尝试调用 subdomain.com/api/test 我得到404 Not Found
但 subdomain.com 工作正常所以我不知道
我的问题出在哪里index.php 文件
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/
require __DIR__.'/vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
这里是我的 api.php
Route::get('/test', function () {
return json_encode(Twitter::getMentionsTimeline(['screen_name' => 'abanoubwagih94', 'count' => 200, 'include_rts' => '1']));
});
有.htaccess 我不知道如何设置它来访问我的子域
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
任何帮助请...
解决方案
推荐阅读
- express - 使用 Mongoose 预保存挂钩会导致:错误 [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
- oracle - oracle 中的通用触发器
- ios - iOS:获取动态数量的子视图以在水平和垂直方向上占用superview中的最大空间
- c# - 在点网核心中初始化后台服务的正确方法
- python - 如何在windows中并行执行多个python代码
- regex - 正则表达式在 openrefine 中搜索和替换表情符号
- loops - 在 for-each 循环中进行类型转换
- nginx - Nginx upd 负载平衡请求仅重定向到一台服务器
- javascript - JavaScript - 在从 JSON 数组中获取数据时用锚标记替换字符串
- javascript - 在 JavaScript 对象中按值查找