php - Symfony .htaccess - 500 third level domain
问题描述
I'm my application on subdirectory in www.example.com/aplication/v1 and I have a third level domain to this in v1.example.com. I'm using symfony2 and in my .htacess I have this:
DirectoryIndex app.php
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /app.php/
</IfModule>
</IfModule>
and this is my app.php
<?php
use Symfony\Component\HttpFoundation\Request;
require __DIR__.'/../app/autoload.php';
include_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('prod', true);
$kernel->loadClassCache();
//$kernel = new AppCache($kernel);
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
//Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
All works well in www.example.com/aplication/v1, but 500 if I try v1.example.com. I ask to support of my hosting and They say the problem is in my .htacess. How fix it?
update: Maybe I must update my rewrite condition in .htaccess?
解决方案
我解决了这个问题,再次将重定向添加到第三个域级别,如下所示:
#redirect for service
RewriteCond %{HTTPS_HOST} ^v1\.example\.com
RewriteRule ^(.*)$ /application/v1/$1 [L]
我不认为我必须重定向我项目下的所有请求,而不仅仅是根。
推荐阅读
- javascript - asp.net 使用 sql 数据创建动态网格并使其可编辑
- c - 由于 PROTOBUF 服务器中的字符串数据类型变量和客户端通过 c 中 recv 端的套接字通信而出现段错误
- javascript - CSS如何在另一个完成后启动一个关键帧动画?
- go - 为什么我们在下面的脚本中添加 &,如果它对结果没有任何改变?
- tendermint - LotionJS 同行发现 | 地址 [...] 不包含 ID
- javascript - 从 javascript (nightwatch.js) 的下拉菜单中选择随机值
- python - 鼠标悬停时使用 selenium Xpath 选择图形的元素
- angular6 - 如何在 Angular 路由中嵌套 1 级以上的路由?
- php - 如何解决意外的“->”(T_OBJECT_OPERATOR)错误?
- python - python将嵌套的整数列表的字符串表示形式转换为嵌套的整数列表