Symfony .htaccess-500第三级域

时间:2018-09-03 11:30:13

标签: php .htaccess symfony

我是我在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中的重写条件?

1 个答案:

答案 0 :(得分:0)

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

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

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

相关问题