Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: HTTP to HTTPS redirect advice

  1. #1
    Join Date
    Nov 2011
    Location
    Cider Region
    Posts
    1,085
    Thanks
    157
    Thanked 3 Times in 3 Posts

    Default HTTP to HTTPS redirect advice

    Hi,
    I have move my site from HTTP to HTTPS and 99% happy when moving to another host.
    I am currently still with the old host but havent advised them yet that ive gone with another.


    The 1% is the following.
    Here is the new HTTPS index page https://www.theremotedoctor.co.uk/index.html & from here you can navigate no problem where links & photos etc work as they should.

    If you visit the old url index page http://www.theremotedoctor.co.uk/index.html with a htaccess in place clicking on a drop down or link etc downloads the file as opposed to opening the html page.

    If i remove the htaccess file & then click a drop down etc it then opens up the correct item BUT with the HTTPS in the url which is great.

    So my issue is the htaccess file causes an issue.
    Looking on google etc for items that i sell or services i provide then clicking on an old link etc downloads the file as opposed to opening the page where the redirect should then be doing its job.

    Thanks

  2. #2
    Join Date
    Nov 2011
    Location
    Cider Region
    Posts
    1,085
    Thanks
    157
    Thanked 3 Times in 3 Posts

    Default

    Hi,
    I didnt know but for me it automatically downloads but for others you see a message box like so



    Click image for larger version. 

Name:	4880.jpg 
Views:	205 
Size:	72.0 KB 
ID:	6333

  3. #3
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Can you post the .htaccess file you are using?

    I couldn't reproduce the problem. You should just be forcing HTTPS through .htaccess, no need to worry if a visitor clicks an old link or doesn't add the "s" to the protocol.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  4. #4
    Join Date
    Nov 2011
    Location
    Cider Region
    Posts
    1,085
    Thanks
    157
    Thanked 3 Times in 3 Posts

    Default

    Hi,
    Since i did this post ive done the following which has now worked.
    Code:
    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 80
    RewriteCond %{HTTP_HOST} ^(www\.)?theremotedoctor\.co.uk
    RewriteRule ^(.*)$ https://www.theremotedoctor.co.uk/$1 [R,L]

    This was my original code file when i was using the http version.
    Im not to sure how to add it to this new code without breaking something.

    Code:
    ## EXPIRES CACHING ##
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access 1 year"
    ExpiresByType image/jpeg "access 1 year"
    ExpiresByType image/gif "access 1 year"
    ExpiresByType image/png "access 1 year"
    ExpiresByType text/css "access 1 month"
    ExpiresByType text/html "access 1 month"
    ExpiresByType application/pdf "access 1 month"
    ExpiresByType text/x-javascript "access 1 month"
    ExpiresByType application/x-shockwave-flash "access 1 month"
    ExpiresByType image/x-icon "access 1 year"
    ExpiresDefault "access 1 month"
    </IfModule>
    ## EXPIRES CACHING ##
    <Files ~ "^\.(htaccess|htpasswd)$">
    deny from all
    </Files>
    Options Indexes
    order deny,allow
    <IfModule mod_headers.c>
      <FilesMatch "\.(js|css|xml|gz)$">
        Header append Vary: Accept-Encoding
      </FilesMatch>
    </IfModule>
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddType application/x-httpd-php .htm .html
    AddType video/ogg  .ogv
    AddType video/mp4  .mp4

  5. #5
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Your most likely culprit is this line:

    Code:
    AddType application/x-httpd-php .htm .html
    Since you switched hosts, they are probably running a different version. This line tells the server to treat html and htm pages as php pages. What is actually happening though, is the php is trying to be served client-side, resulting in a download instead of an execution.

    The AddType is the preferred method, however, some servers run PHP as CGI and the AddType doesn't work, instead you will need AddHandler:

    Code:
    AddHandler application/x-httpd-php .html .htm
    The same will go for your video codecs as well. Also note: Some hosts require the AddHandler to specify which version of PHP is being run, so you may need to do something like:

    Code:
    AddHandler application/x-httpd-php5 .html .htm
    The best thing to do here is to Google ".htaccess run html as php on {your hosting provider}" It will most likely bring up their knowledge base or a forum that will tell you the exact AddHandler type to use.

    The first code you use there forces HTTPS, which is always good. Just throw it at the very top of the rest of the code.

    ~BLiZZ
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  6. #6
    Join Date
    Nov 2011
    Location
    Cider Region
    Posts
    1,085
    Thanks
    157
    Thanked 3 Times in 3 Posts

    Default

    So yesterday before i added those 4 lines that allowed it to work it was doing this below.

    Click image for larger version. 

Name:	335.jpg 
Views:	205 
Size:	70.5 KB 
ID:	6334

  7. #7
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Yeah. That sounds like a problem with the AddType vs AddHandler I mentioned. Switch your AddType lines to AddHandler and it should be fine.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  8. #8
    Join Date
    Nov 2011
    Location
    Cider Region
    Posts
    1,085
    Thanks
    157
    Thanked 3 Times in 3 Posts

    Default

    Well im struggling with this,
    Going by my original code that was is use with the last host,
    Then the code in use at present just to have it working,
    Then trying to merge them ive come up with this.
    Code:
    AddHandler application/x-httpd-php .html .htm
    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 80
    RewriteCond %{HTTP_HOST} ^(www\.)?theremotedoctor\.co.uk
    RewriteRule ^(.*)$ https://www.theremotedoctor.co.uk/$1 [R,L]
    ## EXPIRES CACHING ##
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access 1 year"
    ExpiresByType image/jpeg "access 1 year"
    ExpiresByType image/gif "access 1 year"
    ExpiresByType image/png "access 1 year"
    ExpiresByType text/css "access 1 month"
    ExpiresByType text/html "access 1 month"
    ExpiresByType application/pdf "access 1 month"
    ExpiresByType text/x-javascript "access 1 month"
    ExpiresByType application/x-shockwave-flash "access 1 month"
    ExpiresByType image/x-icon "access 1 year"
    ExpiresDefault "access 1 month"
    </IfModule>
    ## EXPIRES CACHING ##
    <Files ~ "^\.(htaccess|htpasswd)$">
    deny from all
    </Files>
    Options Indexes
    order deny,allow
    <IfModule mod_headers.c>
      <FilesMatch "\.(js|css|xml|gz)$">
        Header append Vary: Accept-Encoding
      </FilesMatch>
    </IfModule>
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddHandler video/ogg  .ogv
    AddHandler video/mp4  .mp4
    Having said that i still get a 403 error advising me i do not have permission to look/edit etc the index file.
    The only way at present for me to have it working is this,
    Code:
    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 80
    RewriteCond %{HTTP_HOST} ^(www\.)?theremotedoctor\.co.uk
    RewriteRule ^(.*)$ https://www.theremotedoctor.co.uk/$1 [R,L]
    I dont even know what the old code does but like to put it in and have it there.
    The videos etc work fine with it but not sure about other browsers etc.

  9. #9
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Save your old htaccess file to your computer and then delete it from your server. Create a brand new one and put this inside:

    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
    ## EXPIRES CACHING ##
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access 1 year"
    ExpiresByType image/jpeg "access 1 year"
    ExpiresByType image/gif "access 1 year"
    ExpiresByType image/png "access 1 year"
    ExpiresByType text/css "access 1 month"
    ExpiresByType text/html "access 1 month"
    ExpiresByType application/pdf "access 1 month"
    ExpiresByType text/x-javascript "access 1 month"
    ExpiresByType application/x-shockwave-flash "access 1 month"
    ExpiresByType image/x-icon "access 1 year"
    ExpiresDefault "access 1 month"
    </IfModule>
    ## EXPIRES CACHING ##
    
    <Files ~ "^\.(htaccess|htpasswd)$">
    deny from all
    </Files>
    Options Indexes
    order deny,allow
    <IfModule mod_headers.c>
      <FilesMatch "\.(js|css|xml|gz)$">
        Header append Vary: Accept-Encoding
      </FilesMatch>
    </IfModule>
    
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddHandler application/x-httpd-php .html .htm
    AddType audio/ogg .oga
    AddType video/ogg .ogv
    AddType application/ogg .ogg
    AddHandler application-ogg .ogg .ogv .oga
    Save and upload to your server and test. It should be fine. If not, upload the saved one and then let me know.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  10. #10
    Join Date
    Nov 2011
    Location
    Cider Region
    Posts
    1,085
    Thanks
    157
    Thanked 3 Times in 3 Posts

    Default

    Morning,
    I have left the site so you can see whats going on.

    The .htaccess file that was in use was using this code of which i have saved on the pc.
    My host is Godaddy

    Code:
    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 80
    RewriteCond %{HTTP_HOST} ^(www\.)?theremotedoctor\.co.uk
    RewriteRule ^(.*)$ https://www.theremotedoctor.co.uk/$1 [R,L]
    The code that has been uploaded is what you have advised above.
    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
    ## EXPIRES CACHING ##
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access 1 year"
    ExpiresByType image/jpeg "access 1 year"
    ExpiresByType image/gif "access 1 year"
    ExpiresByType image/png "access 1 year"
    ExpiresByType text/css "access 1 month"
    ExpiresByType text/html "access 1 month"
    ExpiresByType application/pdf "access 1 month"
    ExpiresByType text/x-javascript "access 1 month"
    ExpiresByType application/x-shockwave-flash "access 1 month"
    ExpiresByType image/x-icon "access 1 year"
    ExpiresDefault "access 1 month"
    </IfModule>
    ## EXPIRES CACHING ##
    
    <Files ~ "^\.(htaccess|htpasswd)$">
    deny from all
    </Files>
    Options Indexes
    order deny,allow
    <IfModule mod_headers.c>
      <FilesMatch "\.(js|css|xml|gz)$">
        Header append Vary: Accept-Encoding
      </FilesMatch>
    </IfModule>
    
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddHandler application/x-httpd-php .html .htm
    AddType audio/ogg .oga
    AddType video/ogg .ogv
    AddType application/ogg .ogg
    AddHandler application-ogg .ogg .ogv .oga
    Here is the link for my site https://www.theremotedoctor.co.uk/index.html

    With that code i see the following error message.

    Click image for larger version. 

Name:	4894.jpg 
Views:	200 
Size:	64.7 KB 
ID:	6335

Similar Threads

  1. Replies: 0
    Last Post: 04-16-2013, 07:44 AM
  2. Need to iframe an https layered url on an http site
    By avdistribution in forum Looking for such a script or service
    Replies: 0
    Last Post: 05-14-2008, 03:08 AM
  3. http/ https problem
    By gavintat in forum PHP
    Replies: 2
    Last Post: 02-19-2008, 06:03 AM
  4. How to redirect to a HTTPS pages using DD script
    By ajaxdude in forum Dynamic Drive scripts help
    Replies: 5
    Last Post: 12-14-2006, 06:12 AM
  5. Access https in http page
    By ymdomar in forum JavaScript
    Replies: 3
    Last Post: 12-13-2006, 01:17 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •