如何为通过https访问的cakephp应用程序修复“在此服务器上未找到的webroot /”?

时间:2019-06-21 17:34:12

标签: php .htaccess cakephp https

我有一个运行并且在线的Cakephp 3.5.x应用程序。

通过 http ://www.xy.de/intern/users/login访问该页面,一切正常。

使用 https ://www.xy.de/intern/users/login访问页面时,出现以下错误:

  

请求的地址'/ webroot / users / login'   在此服务器上找不到。

如何配置应用程序,以便https能正常工作?

我尝试了很多更改.htaccess文件的方法,但直到现在都无济于事。

我当前的.htaccess文件如下:

.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>

webroot / .htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

在cakephp日志中,出现以下错误:

Error: [Cake\Routing\Exception\MissingControllerException] Controller class Webroot could not be found.
    Request URL: /webroot/users/login
    Stack Trace:
    #0 vendor/cakephp/cakephp/src/Http/ControllerFactory.php(38): Cake\Http\ControllerFactory->missingController(Object(Cake\Http\ServerRequest))
    #1 vendor/cakephp/cakephp/src/Http/ActionDispatcher.php(90): Cake\Http\ControllerFactory->create(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
    #2 vendor/cakephp/cakephp/src/Http/BaseApplication.php(103): Cake\Http\ActionDispatcher->dispatch(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
    #3 vendor/cakephp/cakephp/src/Http/Runner.php(65): Cake\Http\BaseApplication->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
    #4 vendor/cakephp/cakephp/src/Routing/Middleware/RoutingMiddleware.php(107): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
    #5 vendor/cakephp/cakephp/src/Http/Runner.php(65): Cake\Routing\Middleware\RoutingMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
    #6 vendor/cakephp/cakephp/src/Routing/Middleware/AssetMiddleware.php(88): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
    #7 vendor/cakephp/cakephp/src/Http/Runner.php(65): Cake\Routing\Middleware\AssetMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
    #8 vendor/cakephp/cakephp/src/Error/Middleware/ErrorHandlerMiddleware.php(95): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
    #9 vendor/cakephp/cakephp/src/Http/Runner.php(65): Cake\Error\Middleware\ErrorHandlerMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
    #10 vendor/cakephp/cakephp/src/Http/Runner.php(51): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
    #11 vendor/cakephp/cakephp/src/Http/Server.php(81): Cake\Http\Runner->run(Object(Cake\Http\MiddlewareQueue), Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
    #12 webroot/index.php(40): Cake\Http\Server->run()
    #13 {main}

该应用程序托管在strato.de上,因此我无法完全控制服务器设置。

我还联系了strato的服务热线,得到的答案是我的目标对他们来说太技术性了。

同一网站空间中未使用cakephp的所有其他页面都可以与https正常工作。

比较来自webroot / index.php的$ _SERVER值,向我显示以下结果:

http:

"SCRIPT_URL":"/intern/users/login",
"SCRIPT_URI":"http://www.xy.de/intern/users/login",
"REQUEST_URI":"/intern/users/login",

https:

"SCRIPT_URL":"/intern/webroot/users/login",
"SCRIPT_URI":"https://www.xy.de/intern/webroot/users/login",
"REQUEST_URI":"/intern/webroot/users/login",

一样:

"PHP_SELF":"/intern/webroot/index.php",

但是我不知道这些差异来自何处以及如何解决。

0 个答案:

没有答案