cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to redirect my website for both www to non www or non www to www afters ssl

 

here is my htaccess file

 

# BEGIN GD-SSL
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_USER_AGENT} ^(.+)$
RewriteCond %{SERVER_NAME} ^tollfreesupportnumbers\.com$ [OR]
RewriteCond %{SERVER_NAME} ^www\.tollfreesupportnumbers\.com$
RewriteRule .* https://%{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 /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

1 REPLY 1
Helper I

RewriteEngine on

# Redirect to domain without www.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule .* http://%1%{REQUEST_URI} [R=301,L]
# Same for HTTPS:
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule .* https://%1%{REQUEST_URI} [R=301,L]

# Redirect to another domain: tollfreesupportnumbers.com.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^(www\.)?tollfreesupportnumbers\.com$ [NC]
RewriteRule .* http://tollfreesupportnumbers.com%{REQUEST_URI} [R=301,L]
# Same for HTTPS:
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^(www\.)?tollfreesupportnumbers\.com$ [NC]
RewriteRule .* https://tollfreesupportnumbers.com%{REQUEST_URI} [R=301,L]

# 301 Redirect URLs.
Redirect 301 /tollfreesupportnumbers.com https://tollfreesupportnumbers.com