Mobile app version of vmapp.org
Login or Join
Kimberly868

: Why does my .htaccess work for all browsers but Internet Explorer? The code .htaccess below is working on all browsers, except for IE (I tested it on IE10 and IE11). The goal is to redirect

@Kimberly868

Posted in: #Htaccess #InternetExplorer #Redirects

The code .htaccess below is working on all browsers, except for IE (I tested it on IE10 and IE11). The goal is to redirect all HTTP traffic to HTTPS, but IE seems to ignore it. Does IE need specific code?

# BEGIN GD-SSL
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_USER_AGENT} ^(.+)$
RewriteCond %{SERVER_NAME} ^domain.com$
RewriteRule .* %{SERVER_NAME}%{REQUEST_URI} [R=301,L]
Header add Strict-Transport-Security "max-age=300"
</IfModule>
# END GD-SSL


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.(.+)$
RewriteRule ^(.*)$ %1/ [R=301,L]
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress


On Firefox, Safari and Chrome if I access any of these:
domain.com http://www.domain.com www.domain.com

I am redirected to domain.com
On IE I am not redirected, or I am redirected to HTTP (not HTTPS).

Any ideas as to why?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Kimberly868

2 Comments

Sorted by latest first Latest Oldest Best

 

@Sherry384

In the section marked:

# BEGIN GD-SSL


You can safely delete the line:

RewriteCond %{HTTP_USER_AGENT} ^(.+)$


This is causing your problem though for the life of me I cannot figure out why this line exists. It is a do nothing line really but somehow it did not match the agent name IE was giving. The general rule when doing regular expressions is the match the least first- meaning match only what is necessary. The reason for this is simple. Matching too much always has unintended consequences.

One other thing: And this is important- clear your browser cache just in case. We all have done it. We have fixed a problem, forgot to clear the cache, then think the problem is not solved and try and find another solution. Think Homer Simpson- Dooh!!

10% popularity Vote Up Vote Down


 

@Berumen354

Try checking if the port being requested is 80 instead of 443. If 80, redirect to HTTPS.

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ domain.com/ [R,L]
Header add Strict-Transport-Security "max-age=300"
</IfModule>

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme