Question

I've read into this quite a bit but can't seem to find a solution. I'm trying to set it so whenever someone visits a link for my site (and for whatever reason they don't include https it redirects to the page they linked and https)

Example: 
www.mywebsite.com/category1/product2 
redirects to 
https://www.mywebsite.com/category1/product2 

Currently it does the following:
www.mywebsite.com/category1/product2
redirects to
https://www.mywebsite.com

My .htaccess includes:

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

And my settings are enter image description here

So how can I make it so whenever someone is given a VALID url but it doesn't have the valid authentication, they are automatically taken to the https version of that page?

TIA

EDIT My .htaccess

############################################
#### Headers for performance

<ifModule mod_headers.c> 
Header set Connection keep-alive 
</ifModule>

############################################
#### File Blocks for security

    <Files cron.php>
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1
    </Files>

    <Files cron.sh>
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1
    </Files>

############################################
#### Rewrite for index.php

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

############################################
## 503 Maintenance mode
#RewriteEngine on
#RewriteCond %{REQUEST_URI} !^/maintenance/
#RewriteCond %{REMOTE_HOST} !^127\.0\.0\.1$
#RewriteRule .* index.php [R=503,L]
#ErrorDocument 503 /maintenance/index.html

############################################
## default index file

    DirectoryIndex index.php

<IfModule mod_php5.c>

############################################
## disable magic quotes for php request vars

    php_flag magic_quotes_gpc off

############################################
## disable automatic session start
## before autoload was initialized

    php_flag session.auto_start off

###########################################
# disable user agent verification to not break multiple image upload

    php_flag suhosin.session.cryptua off

###########################################
# turn off compatibility with PHP4 when dealing with objects

    php_flag zend.ze1_compatibility_mode Off

</IfModule>

<IfModule mod_security.c>
###########################################
# disable POST processing to not break multiple image upload

    SecFilterEngine Off
    SecFilterScanPOST Off
</IfModule>

<IfModule mod_ssl.c>

############################################
## make HTTPS env vars available for CGI mode

    SSLOptions StdEnvVars

</IfModule>

<IfModule mod_rewrite.c>

############################################
## enable rewrites

    Options +FollowSymLinks
    RewriteEngine on

############################################
## rewrite API2 calls to api.php (by now it is REST only)

    RewriteRule ^api/rest api.php?type=rest [QSA,L]

############################################
## workaround for HTTP authorization
## in CGI environment

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]


############################################
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks

    RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
    RewriteRule .* - [L,R=405]

############################################
## always send 404 on missing files in these folders

    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

############################################
## never rewrite for existing files, directories and links

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

############################################
## rewrite everything else to index.php

    RewriteRule .* index.php [L]

</IfModule>


############################################
## Prevent character encoding issues from server overrides
## If you still have problems, use the second line instead

    AddDefaultCharset Off
    #AddDefaultCharset UTF-8

<IfModule mod_expires.c>

############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires

    ExpiresDefault "access plus 1 year"

</IfModule>

############################################
## By default allow all access

    Order allow,deny
    Allow from all

###########################################
## Deny access to release notes to prevent disclosure of the installed Magento version

    <Files RELEASE_NOTES.txt>
        order allow,deny
        deny from all
    </Files>

###########################################
## gzip

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

SetEnvIf Request_URI ^/index.php/api/ no-gzip=1

############################################
## enable apache served files compression (not php, html/images/css/js
## http://developer.yahoo.com/performance/rules.html#gzip

<IfModule mod_deflate.c>
# Insert filter on all content
SetOutputFilter DEFLATE
# Insert filter on selected content types only
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>


############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 14 days"
</IfModule>
Était-ce utile?

La solution

I fixed it by adding

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://mydomain.co.uk/$1 [L,R=301]

To my .htaccess and setting Auto-Redirect to base url to No

Hope this helps someone

Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top