【发布时间】:2018-12-16 02:08:47
【问题描述】:
我是 www.example.com/aplication/v1 子目录中的应用程序,我在 v1.example.com 中有一个第三级域。 我正在使用 symfony2,在我的 .htacess 中有这个:
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>
这是我的 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);
在 www.example.com/aplication/v1 中一切正常,但如果我尝试 v1.example.com,则为 500。 我要求支持我的托管,他们说问题出在我的 .htacess 中。 如何解决?
更新:也许我必须在 .htaccess 中更新我的重写条件?
【问题讨论】:
-
我怀疑这与require和include有关...
-
我也怀疑这一点,但我怎样才能设置重定向适用于两个域?
-
只使用绝对路径
-
这不行,我想是因为我使用 symfony 并且这个文件是受保护的(用绝对路径看不到)。
-
错误日志中是否出现错误? /var/log/apache2/...