Not logged in. · Lost password · Register
Forum: General Help and Support Installation and Configuration RSS
Nice URL and force HTTPS
Avatar
david59 #1
Member since Jan 2019 · 6 posts
Group memberships: Members
Show profile · Link to this post
Subject: Nice URL and force HTTPS
Hello,

I've read https://www.dokuwiki.org/rewrite and https://www.dokuwiki.org/tips:httpslogin

Individually, each one is working :
- I can set my .htaccess to have nice urls
- I can set my .htaccess to force HTTPS

But when I try putting both the parameters in my .htaccess, everything goes wrong.

I've read a few forum posts about .htaccess issues but haven't seen one having my exact issue.

So on one side I have this for "Nice URL" :
RewriteEngine on
RewriteBase /

RewriteRule ^_media/(.*)              lib/exe/fetch.php?media=$1  [QSA,L]
RewriteRule ^_detail/(.*)             lib/exe/detail.php?media=$1  [QSA,L]
RewriteRule ^_export/([^/]+)/(.*)     doku.php?do=export_$1&id=$2  [QSA,L]
RewriteRule ^$                        doku.php  [L]
RewriteCond %{REQUEST_FILENAME}       !-f
RewriteCond %{REQUEST_FILENAME}       !-d
RewriteRule (.*)                      doku.php?id=$1  [QSA,L]
RewriteRule ^index.php$               doku.php

And on the other, I have this for forcing HTTPS :
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

How do I have to mix them to have nice urls forced in HTTPS ?

Thank you
Avatar
Michaelsy #2
Member since Jun 2015 · 969 posts · Location: Düsseldorf, Germany
Group memberships: Members
Show profile · Link to this post
Try this:

RewriteEngine on
RewriteBase /

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteRule ^_media/(.*)              lib/exe/fetch.php?media=$1  [QSA,L]
RewriteRule ^_detail/(.*)             lib/exe/detail.php?media=$1  [QSA,L]
RewriteRule ^_export/([^/]+)/(.*)     doku.php?do=export_$1&id=$2  [QSA,L]
RewriteRule ^$                        doku.php  [L]
RewriteCond %{REQUEST_FILENAME}       !-f
RewriteCond %{REQUEST_FILENAME}       !-d
RewriteRule (.*)                      doku.php?id=$1  [QSA,L]
RewriteRule ^index.php$               doku.php

Not tested by me! But a comparable case works for me.

Feedback welcome - Michael Sy.
By Patreon.com a few eurons can be fed into the code phasers of
the DokuWiki engine. Besides, Andi's posts are worth reading.
Avatar
david59 #3
Member since Jan 2019 · 6 posts
Group memberships: Members
Show profile · Link to this post
Thank you for your answer.

Unfortunately it doesn't work, I got a ERR_TOO_MANY_REDIRECTS error on my browser.

It's realy weird because for Wordpress I have a htaccess very similar that works very fine...

Anyway, thank you for trying to help me !
Avatar
Michaelsy #4
Member since Jun 2015 · 969 posts · Location: Düsseldorf, Germany
Group memberships: Members
Show profile · Link to this post
ERR_TOO_MANY_REDIRECTS

Maybe the cause is a loop. (The 301 reply is given again and again.)

With a small chance, this little change could help:
(Not really, but you should try it.)

RewriteCond %{HTTPS} off
to
RewriteCond %{HTTPS} !=on


Please give me your Wordpress htaccess.
By Patreon.com a few eurons can be fed into the code phasers of
the DokuWiki engine. Besides, Andi's posts are worth reading.
Avatar
turnermm (Moderator) #5
Member since Oct 2009 · 4690 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
In reply to post #1
I've been successfully using dokuwiki's default configuration, with the off parameter and the https condition at the end of the file.  If this isn't working for you, and if nice urls is set to htaccess, perhaps you might have to check your apache configuration. Maybe, for instance, there is a disconnect between your main config and the ssl.conf.  Try checking the error logs-- error_log on Centos, error.log on Ubuntu-- and the ssl error log
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Avatar
david59 #6
Member since Jan 2019 · 6 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #4
Like you imagined, it doesn't work either. Exactly the same error.

My Wordpress htaccess is :

#RewriteCond %{HTTPS} off
#RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

#<IfModule mod_rewrite.c>
#RewriteEngine On
#RewriteBase /
#RewriteCond %{SERVER_PORT} !^443$
#RewriteCond %{HTTPS} off
#RewriteRule ^(.*)$ https://www.domain.tld/$1 [R=301,L]
#RewriteRule ^index\.php$ - [L]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule . /index.php [L]
#</IfModule>

It looks like the "force HTTPS" is done twice here, but since I don't have access to the server on which it is (I got it from today's backup files), I can't try to change my Wordpress htaccess.
Avatar
david59 #7
Member since Jan 2019 · 6 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #5
Okay, so after trying to access to the vhost conf and the log (the problematic install is on a "shared" server*) and without success, I transfered everything "as it" on a dedicated and... voilà. Everything works fine.

So I guess it's totaly on the provider if that doesn't work.

I will contact it to try to find a solution, even though, for now, I will host this wiki myself.

Thank you for your help !

*hébergement mutualisé in french, doesn't know the correct english version...
Avatar
Michaelsy #8
Member since Jun 2015 · 969 posts · Location: Düsseldorf, Germany
Group memberships: Members
Show profile · Link to this post
In the meantime, I had already come up also with the idea that we are looking at the wrong place here.

Quote by david59:
*hébergement mutualisé in french, doesn't know the correct english version...

hébergement mutualisé => shared hosting / shared hosting server
(In German: Shared Hosting / Shared Hosting Server  :-) )

Good luck!
By Patreon.com a few eurons can be fed into the code phasers of
the DokuWiki engine. Besides, Andi's posts are worth reading.
This post was edited on 2019-01-17, 15:59 by Michaelsy.
Avatar
david59 #9
Member since Jan 2019 · 6 posts
Group memberships: Members
Show profile · Link to this post
Thank you for the vocabulary !
Avatar
Michaelsy #10
Member since Jun 2015 · 969 posts · Location: Düsseldorf, Germany
Group memberships: Members
Show profile · Link to this post
Another try (I guess, a good chance):

# http to https redirect
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Source: https://stackoverflow.com/questions/45285014/http-to-https…

Edit: If that works, then I suspect that the https-redirect of Wordpress is implemented itself by the provider via the front-end server. The corresponding rules in the htaccess file of Wordpress are then waste.
By Patreon.com a few eurons can be fed into the code phasers of
the DokuWiki engine. Besides, Andi's posts are worth reading.
This post was edited 2 times, last on 2019-01-18, 13:58 by Michaelsy.
Avatar
turnermm (Moderator) #11
Member since Oct 2009 · 4690 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
The worpress .htaccess is totally commented out.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Avatar
Michaelsy #12
Member since Jun 2015 · 969 posts · Location: Düsseldorf, Germany
Group memberships: Members
Show profile · Link to this post
Quote by turnermm:
The worpress .htaccess is totally commented out.
Only Myron can recognize as precisely as a computer!  :-)
By Patreon.com a few eurons can be fed into the code phasers of
the DokuWiki engine. Besides, Andi's posts are worth reading.
Avatar
david59 #13
Member since Jan 2019 · 6 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #11
Nice catch !

I copied it from the .htaccess I was using for my DokuWiki installation, it was commented to use it as an exemple for what I was trying to make succesfull.

In my real .htaccess for Wordpress, all the rules aren't commented of course !
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2019-08-24, 02:20:36 (UTC +02:00)