.htaccess https breaks rewrite rules

2019-09-03 23:13发布

I am experienceing some .htaccess redirect issues.

Mainly I do not care if the user is on https unless I send them there, I have found alot of resources on how to force https, but that is not what I am trying to do.

this is a example of my htaccess:

Options -Indexes
Options -MultiViews

<filesMatch "\.(html|htm|txt|js|htaccess)$">
FileETag None
    <ifModule mod_headers.c>
        Header unset ETag
        Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
        Header set Pragma "no-cache"
        Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
    </ifModule>
</filesMatch>

ErrorDocument 404 /404.php 

RewriteEngine On

#RewriteCond %{HTTPS} !=on
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

#Main site rules
RewriteRule    ^about/?$     about.php    [NC,L]

I am able to force https using:

#RewriteCond %{HTTPS} !=on
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

But then the example rule which redirects to about.php does not work.

How do I allow for https in my redirects?

I also experimented with:

Define servername www.example.com
Define SSL

But I did not understand its function or implementation.

标签: .htaccess ssl
0条回答
登录 后发表回答