Nette n00b – site is returning 301 between https and http!
- vyedmic
- Member | 4
Hello,
First, please excuse me but I don't know Nette at all. I host a website that was developed in Nette and I was asked to also provide https version. When I copy the site into a folder served through https, the site creates a 301 loop which loops between http and https versions!
I have disabled the rewrite engine and searched the code for any explicit links to the original http version. No luck. I have symlinked the exact same folder that is served over http, but the problem remains.
I don't know which version of Nette I'm running and how to use the debugger. I noticed there are some Latte templates. I tested it both with Apache 2.2 and Apache 2.4 with the same result. I don't know where to go from here. Does anyone have any ideas please? Thanks.
- enumag
- Member | 2118
To my knowledge Nette never redirects from https to http, only the other way around if you have the SECURED flag in your router.
My guess is that your apache for some reason redirects all https addresses to http (which means this should occur even without nette). And nette then tries to redirect back https which creates the loop.
So first try to run some non-nette hello world HTML page over https. It shouldn't work without some modifications to your apache configuration. After you fix that it should be fine.
- David Grudl
- Nette Core | 8218
It is correct behavior, because http://www.example.com
and
https://www.example.com
are completely different web sites, so
first one (http) should redirect to https.
- David Matějka
- Moderator | 6445
@enumag I think, it also redirects from https to http if SECURED flag is not present in the router.. see this line
@vyedmic
Try add this line
\Nette\Application\Routers\Route::$defaultFlags |= \Nette\Application\IRouter::SECURED;
to app/bootstrap.php (before line
$container = $configurator->createContainer()
)
Last edited by matej21 (2014-10-02 01:05)
- vyedmic
- Member | 4
We're getting somewhere! Instead of the 301 loop I got this:
Nette\Debug FATAL ERROR: thrown DirectoryNotFoundException: Directory '*ANONYMISED BY VYEDMIC*/_app/../log' is not found or is not directory. while processing FatalErrorException: Class 'Nette\Application\Routers\Route' not found
Last edited by vyedmic (2014-10-02 01:21)
- David Matějka
- Moderator | 6445
@vyedmic it seems it is nette 0.9, try this:
\Nette\Application\Route::$defaultFlags |= \Nette\Application\IRouter::SECURED;
Last edited by matej21 (2014-10-02 12:20)