• 0

Help with Domain Name and IP Redirection


Question

Can someone help me with redirecting a domain name to the HTTPS version of itself?  I've seen many examples online but none of them seems to fit my specific requirements.

 

I think I need multiple "if" conditions that will redirect any non-"https://www" queries to the "https://www" version of itself.

 

Below is the 301 redirection options I need to include in the .htaccess file:

 

 Routing-Table.thumb.png.d04f63ab7358df43c6012f2427c04c10.png

 

From the above table, you'll notice that I need at least 3 condition checks within my single .htaccess file. Also, as I'm using the same .htaccess file in my localhost as well as on my public web site, the "if" conditions will also need to accommodate localhost as well.

 

I can only test for either A, B or C from the list above.  I can't test a combination of all of them.

 

Please can a kind Neowin expert assist me?

 

Thank you.

 

 

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

Why would the standard redirect all to https not work?

 


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

 

Why would you be using local host and not just use fqdn www.test.com that resolve to your local IP your site is listening on?  Be simple host file on your local machine for that matter.

 

You should be able to replace the variables with the exact fqdn you want to use https://www.test.com

Link to comment
Share on other sites

  • 0

What?  Makes Zero sense.. Did you post your answer to some other thread?  What you ask has zero to do with any routing table.

Link to comment
Share on other sites

  • 0

There is a actual "table", in my post (click here to see it), it illustrates the place the user start at and where I want them to end at (a "route").

 

So if a user tries "test.com",  they end up at "https://www.test.com",

If a user tries "www.test.com",  they end up at "https://www.test.com",

If a user tries "https://test.com",  they end up at "https://www.test.com",

If a user tries "255.255.255.255",  they end up at "https://www.test.com",

And also,

If a user tries "localhost",  they end up at "https://localhost".

If a user tries "brianpc",  they end up at "https://brianpc".

If a user tries "192.186.0.100",  they end up at "https://brianpc".

 

Original question was too confusing.  I hope you can help.

Thank you.

Link to comment
Share on other sites

  • 0

Already answered dude.. I gave you the code to redirect anything http to https which can be edited to go exactly where you want vs what they send..

Link to comment
Share on other sites

  • 0

Thanks Bud but you didn't exact answer the question. Redirecting https to https is easy but my questions was not to redirect http > https; it was to redirect multiple states of the URL to https://www.  So the actual question remains unanswered.  If it helps you, read this message, and see if you actually answered my question or not.

Link to comment
Share on other sites

  • 0
45 minutes ago, Brian Miller said:

it was to redirect multiple states of the URL to https://www.

Dude yes the information redirects whatever they send to that via https, you can just edit it to go www.something.com

 

This is not all that difficult...  Here.. Lets go through it line by line

 

A,B and C - YES

D - Again yes..

EFG - Yes once again... But Freaking why??  Are you too freaking lazy to just go to https://www.domain.tld

 

And have that resolve to whatever your localhost box IP is? via simple entry in your host file on your host or via your dns you run on your network.  But to be honest your running Apache you should just do it via a redirect in your conf

 

http://httpd.apache.org/docs/current/rewrite/avoid.html#redirect

<VirtualHost *:80>
    ServerName www.example.com
    Redirect / https://www.example.com/
</VirtualHost>

<VirtualHost *:443>
    ServerName www.example.com
    # ... SSL configuration goes here
</VirtualHost>

 

Also if you want your using to use https you should really be setting up HSTS..

Link to comment
Share on other sites

This topic is now closed to further replies.