【问题标题】:Symfony .htaccess - 500 third level domainSymfony .htaccess - 500 三级域
【发布时间】: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/...

标签: php .htaccess symfony


【解决方案1】:

我解决了这个问题,再次添加重定向到第三个域级别,如下所示:

 #redirect for service
    RewriteCond %{HTTPS_HOST} ^v1\.example\.com
    RewriteRule ^(.*)$ /application/v1/$1 [L]

我不认为我必须重定向我项目下的所有请求,而不仅仅是根。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-21
    • 1970-01-01
    • 2016-04-09
    • 2015-07-20
    • 1970-01-01
    相关资源
    最近更新 更多