Also in my domain's root, theres a index.php file to forward all root-requests to /x3/:
Gonna be honest with you, I don't quite understand why you need to use a redirect in the first place. Redirecting delays the server response, and it needs to make two requests to get to a URL. Especially slow if you need an intermediate PHP request to redirect. Why you don't have X3 in the root of your domain if you are redirecting it anyway? Apart from this, the only thing your index.php does, is redirect a request if it lands in root ... It does not force SSL for ALL request on your server, as is what you need. For example, this image works:
http://www.240.ch/x3/render/w480-c1:1-q ... PR0581.jpg
All requests should be forced to use HTTPS.
RBachmann wrote:To be able to access the gallery by just entering the host/domain of the website, I configured my .htaccess as follows:
[root]/.htaccess:
RewriteEngine On
RewriteCond %{HTTPS} =off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [QSA,L,R=301]
Not quite sure where you have added this, or why you didn't use my example, but this isn't having any effect. The only thing that is working, is your index.php redirect.
RBachmann wrote:All of them are now redirected to https://(www.)240.ch/x3/
That is just because of your index.php, which does nothing more than redirect the root url.
RBachmann wrote:What doesn't work is if a user browses to
http://240.ch/x3/ directly, this call isn't redirected by the root-htaccess to https://...
That makes sense as the user didn't request the root of the domain, right.
It makes sense because your htaccess rule does not have any effect, and im not sure why you didn't use my example. My examples forces ALL requests to ANY page/file/root/subfolder, and forces the request to SSL/HTTPS. This is how it should be.
RBachmann wrote:To cover this case, I would have to edit the x3's own .htaccess file in [root]/x3/.htaccess, what I would like to avoid. Editing an application's files bears the possibility to get overridden by a future version of x3.
Sure, but I don't see why you can't make an edit to htaccess in the root folder. Even if you needed to edit .htaccess from X3, this is the only way to achieve a proper canonicalization of your dual access (http and https). Ultimately, this should be controlled from your apache config anyway, forcing this domain to only use SSL. Personally, I use Cloudflare, and a simple page-rule "Force SSL for all requests".
RBachmann wrote:Wouldn't it make sense to have an option in x3's panel to enforce redirects from http-requests to https? This way the application's logic (the .htaccess) file wouldn't need to be touched and maintained by the clients.
This is not something we can manage through PHP/application logic. First of all, redirect from PHP is incredibly slow and ineffective, and is not something anyone should apply to PHP instead of using htaccess. But more importantly, what about image requests and all other non-app specific requests? Imagevue X3 doesn't have any control of these requests. Only the .htaccess file native to your Apache server can route and rewrite requests properly and effectively. Basically we don't want to add redirects at all the X3, as that would be no more than slow hacks to compensate for issues which should not exist in the first place, or be solved by htaccess.
With htaccess, you could even setup a redirect to X3 instead of using index.php (slow). Even better, if you for some reason really need to have X3 in a subfolder although you are redirecting your domain there anyway, you could setup a "rewriterule" ... This is much faster than redirect, as it doesn't require redirect, and basically the "x3" segment in the url would simply be removed, while you can still keep the physical folder.
Unfortunately, my knowledge in creating htaccess rules is below par, but if you provided FTP to your server, I could try to set it up properly.