3

This is driving me bananas. For some reason my domain will not work to redirect https-WWW to https-non-WWW. This works with every other permutation except https://www.nextoronto.com

What code do I use in the .htaccess that will allow it to work for all permutations?

Edit: This is the rewrite code now:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.nextoronto\.com [NC]
RewriteRule ^(.*)$ https://nextoronto.com/$1 [L,R=301]
Mike Rockétt
  • 8,947
  • 4
  • 45
  • 81

4 Answers4

2

It looks sound, perhaps that rule isn't being reached due to other rules in front of it?

Here is what I use that works:

# Force SSL
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://nextoronto.com/$1 [R=301,L]

# Redirect www to non-www
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*)$ https://nextoronto.com/$1 [R=301,L]

# My other rewrites for routing all requests to index.php go here...
drew010
  • 68,777
  • 11
  • 134
  • 162
0

Edit the URL and try with this code:

RewriteEngine on
rewritecond %{http_host} ^www\.example\.com [nc]
rewriteCond %{SERVER_PORT} 80 
rewriterule ^(.*)$ https://example.com/$1 [r=301,nc]
flux
  • 108
  • 8
0

Step 1

You should make .htaccess file like this

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ index.php?url=$1

Step 2

Go to the directory, then view mark the option file extension. Then see the .htaccess file.

Waqas_aamer
  • 220
  • 1
  • 3
  • 18
0

When no rewrite works, no matter what you do, consider what happened to me. IIS or WAMP, on my laptop, redirected all calls to my domain (call it example.com) to localhost. So creating all the rewrites on my example.com server were to no avail because no calls to example.com ever made it out of my computer. Just do a "ping example.com" and if you get an IP of 127.0.0.1, edit your HOSTS file.

MChase
  • 21
  • 1