Hi,
I just activate ssl/ts on my blog : install certificate and update blog address in the configuration. It works fine.
I have a problem with redirection.
1. In the root directory I have a htaccess file with this content :
# Redirection vers HTTPS
RewriteCond %{SERVER_PORT} ^80$ [OR]
RewriteCond %{HTTPS} =off
RewriteRule ^(.*)$ https://chabreuil.com/$1 [R=301,L]
# Redirection du www vers non-www en HTTPS
RewriteCond %{HTTP_HOST} ^www\.chabreuil\.com [NC]
RewriteRule ^(.*)$ https://chabreuil.com/$1 [R=301,L]
2. My s9y blog is located in a subdirectory of my site.
Redirection doesn't work with my blog:
http://www.chabreuil.com/Aurore is not redirected to https://
But
http://www.chabreuil.com/montest is redirected to https://
Any idea?
From http to https
From http to https
Fabien Chabreuil (blog)
Re: From http to https
If a .htaccess file exists in a directory then the parent directory's rewrite rules are not inherited. To accomplish that add
RewriteOptions Inherit
to your Aurore/.htaccess file, but be careful other rewrite rules in the parent don't interfere. Alternatively, if you use Apache 2.4.8 or later, you can add the directive
RewriteOptions InheritDownBefore
to the parent (i.e. site global) .htaccess file where you specified the rewrite rule.
See also https://httpd.apache.org/docs/current/m ... write.html
Also, I'd rather use
RewriteCond %{HTTPS} =off
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
If you have modify access to your server's httpd.conf the best would be to have two VirtualHost and let a simple one without SSL redirect to the "real" one with SSLEngine on, like
<VirtualHost *:80>
ServerName chabreuil.com
Redirect 301 / https://chabreuil.com/
</VirtualHost>
and a VirtualHost *:443 or some such should exist, but that highly depends on your server setup.
RewriteOptions Inherit
to your Aurore/.htaccess file, but be careful other rewrite rules in the parent don't interfere. Alternatively, if you use Apache 2.4.8 or later, you can add the directive
RewriteOptions InheritDownBefore
to the parent (i.e. site global) .htaccess file where you specified the rewrite rule.
See also https://httpd.apache.org/docs/current/m ... write.html
Also, I'd rather use
RewriteCond %{HTTPS} =off
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
If you have modify access to your server's httpd.conf the best would be to have two VirtualHost and let a simple one without SSL redirect to the "real" one with SSLEngine on, like
<VirtualHost *:80>
ServerName chabreuil.com
Redirect 301 / https://chabreuil.com/
</VirtualHost>
and a VirtualHost *:443 or some such should exist, but that highly depends on your server setup.
Running s9y at https://erack.net/blog/
Re: From http to https
Thank you erAck for your long and precise answer.
If I use the inherit directive (I have tried the two),
http://www.chabreuil.com/Aurore is redirected to https://www.chabreuil.com
and not to https://www.chabreuil.com/Aurore
Best regards
If I use the inherit directive (I have tried the two),
http://www.chabreuil.com/Aurore is redirected to https://www.chabreuil.com
and not to https://www.chabreuil.com/Aurore
Best regards
Fabien Chabreuil (blog)
Re: From http to https
Sorry for the up but I am stuck.
The problem :
1. My blog is using https and it works.
2. My blog is located in a subdirectory of the root directory of my site.
3. I try to redirect http to https and it works for everything except the blog
http://www.chabreuil.com is redirected to https://www.chabreuil.com
http://www.chabreuil.com/test is redirected to https://www.chabreuil.com/test
4. So the problem is either with s9y or in a conflict between htaccess in the root directory and in htaccess in the blog directory. The former is probably excluded because I have seen a lot of s9y blog with a similar configuration and having not this problem.
htaccess in the root directory is:
htaccess is the blog directory is:
Any idea will be very welcomed!
The problem :
1. My blog is using https and it works.
2. My blog is located in a subdirectory of the root directory of my site.
3. I try to redirect http to https and it works for everything except the blog
http://www.chabreuil.com is redirected to https://www.chabreuil.com
http://www.chabreuil.com/test is redirected to https://www.chabreuil.com/test
4. So the problem is either with s9y or in a conflict between htaccess in the root directory and in htaccess in the blog directory. The former is probably excluded because I have seen a lot of s9y blog with a similar configuration and having not this problem.
htaccess in the root directory is:
Code: Select all
# Redirection vers HTTPS
RewriteCond %{SERVER_PORT} ^80$ [OR]
RewriteCond %{HTTPS} =off
RewriteRule ^(.*)$ https://chabreuil.com/$1 [R=301,L]
# Redirection du www vers non-www en HTTPS
RewriteCond %{HTTP_HOST} ^www\.chabreuil\.com [NC]
RewriteRule ^(.*)$ https://chabreuil.com/$1 [R=301,L]
Code: Select all
# BEGIN s9y
ErrorDocument 404 /Aurore/index.php
DirectoryIndex /Aurore/index.php
Options -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /Aurore/
RewriteRule ^plugins/.+/documentation.*\.html - [L]
RewriteRule ^serendipity_admin.php serendipity_admin.php [NC,L,QSA]
RewriteRule ^((archives/([0-9]+)\-[0-9a-z\.\_!;,\+\-\%]+\.html)/?) index.php?/$1 [NC,L,QSA]
RewriteRule ^(authors/([0-9]+)\-[0-9a-z\.\_!;,\+\-\%]+) index.php?/$1 [NC,L,QSA]
RewriteRule ^(feeds/categories/([0-9;]+)\-[0-9a-z\.\_!;,\+\-\%]+\.rss) index.php?/$1 [NC,L,QSA]
RewriteRule ^(feeds/authors/([0-9]+)\-[0-9a-z\.\_!;,\+\-\%]+\.rss) index.php?/$1 [NC,L,QSA]
RewriteRule ^(categories/([0-9;]+)\-[0-9a-z\.\_!;,\+\-\%]+) index.php?/$1 [NC,L,QSA]
RewriteRule ^archives([/A-Za-z0-9]+)\.html index.php?url=/archives/$1.html [NC,L,QSA]
RewriteRule ^([0-9]+)[_\-][0-9a-z_\-]*\.html index.php?url=$1-article.html [L,NC,QSA]
RewriteRule ^feeds/(.*) index.php?url=/feeds/$1 [L,QSA]
RewriteRule ^unsubscribe/(.*)/([0-9]+) index.php?url=/unsubscribe/$1/$2 [L,QSA]
RewriteRule ^approve/(.*)/(.*)/([0-9]+) index.php?url=approve/$1/$2/$3 [L,QSA]
RewriteRule ^delete/(.*)/(.*)/([0-9]+) index.php?url=delete/$1/$2/$3 [L,QSA]
RewriteRule ^(admin|entries)(/.+)?$ index.php?url=admin/ [L,QSA]
RewriteRule ^archive/? index.php?url=/archive [L,QSA]
RewriteRule ^(index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml) rss.php?file=$1&ext=$2
RewriteRule ^(plugin|plugin)/(.*) index.php?url=$1/$2 [L,QSA]
RewriteRule ^search/(.*) index.php?url=/search/$1 [L,QSA]
RewriteRule ^comments/(.*) index.php?url=/comments/$1 [L,QSA]
RewriteRule ^(serendipity\.css|serendipity_admin\.css)$ index.php?url=/$1 [L,QSA]
RewriteRule ^(serendipity\.js|serendipity_admin\.js)$ index.php?url=/$1 [L,QSA]
RewriteRule ^index\.(html?|php.+) index.php?url=index.html [L,QSA]
RewriteRule ^htmlarea/(.*) htmlarea/$1 [L,QSA]
RewriteRule (.*\.html?) index.php?url=/$1 [L,QSA]
</IfModule>
<Files *.tpl.php>
deny from all
</Files>
<Files *.tpl>
deny from all
</Files>
<Files *.sql>
deny from all
</Files>
<Files *.inc.php>
deny from all
</Files>
<Files *.db>
deny from all
</Files>
# END s9y
Fabien Chabreuil (blog)
Re: From http to https
I just spotted that I omitted the word RewriteOptions from my earlier reply in
RewriteOptions InheritDownBefore
So, to recap, neither of these two work for you?
Either in /.htaccess have
RewriteOptions InheritDownBefore
or in /Aurore/.htaccess have
RewriteOptions Inherit
Don't know if actually related, but make sure that you have https also in Admin -> Configuration -> Paths, URL to blog.
RewriteOptions InheritDownBefore
So, to recap, neither of these two work for you?
Either in /.htaccess have
RewriteOptions InheritDownBefore
or in /Aurore/.htaccess have
RewriteOptions Inherit
Don't know if actually related, but make sure that you have https also in Admin -> Configuration -> Paths, URL to blog.
Running s9y at https://erack.net/blog/
Re: From http to https
Hi erAck,
Thank you to be there and help.
If I add the RewriteOptions to the root htaccess, the situation is worse : either http or https//www.chabreuil.com/Aurore redirect to https://www.chabreuil.com
If I add the RewriteOptions to the root htaccess, same thing: redirect to https://www.chabreuil.com !
Of course, I cleaned the template cache between the tests. I use 2k11.
Yes, the configuration is ok.
Best regards, Fabien
Thank you to be there and help.
If I add the RewriteOptions to the root htaccess, the situation is worse : either http or https//www.chabreuil.com/Aurore redirect to https://www.chabreuil.com
If I add the RewriteOptions to the root htaccess, same thing: redirect to https://www.chabreuil.com !
Of course, I cleaned the template cache between the tests. I use 2k11.
Yes, the configuration is ok.
Best regards, Fabien
Fabien Chabreuil (blog)
Re: From http to https
Try if having just this in /.htaccess makes any difference (note I use a temporary redirect 302 instead of 301 to not entirely confuse the browser.. (you may have to clear its cache from the earlier experiments); if things work satisfyingly change the code to a permanent 301)
If it does, try this:
If that does not work then forget about the non-www vs www for the moment or experiment how to add that.
However, the main difference is the %{REQUEST_URI} instead of the URL path and $1 capture back-reference, for the reason that when the rule is matched in the Aurore/ subdirectory the ^(.*)$ matches relative to that directory thus for example for https://www.chabreuil.com/Aurore/ contains only / which then is used for the new location. %{REQUEST_URI} instead contains the full request /Aurore/.
Code: Select all
RewriteEngine On
RewriteOptions InheritDownBefore
RewriteCond %{HTTPS} !on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
Code: Select all
RewriteEngine On
RewriteOptions InheritDownBefore
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://chabreuil.com%{REQUEST_URI} [R=302,L]
However, the main difference is the %{REQUEST_URI} instead of the URL path and $1 capture back-reference, for the reason that when the rule is matched in the Aurore/ subdirectory the ^(.*)$ matches relative to that directory thus for example for https://www.chabreuil.com/Aurore/ contains only / which then is used for the new location. %{REQUEST_URI} instead contains the full request /Aurore/.
Running s9y at https://erack.net/blog/
Re: From http to https
It works perfectly for www and non-www.
A huge thank you, erAck.
A huge thank you, erAck.
Fabien Chabreuil (blog)