Forum Moderators: phranque

Message Too Old, No Replies

turn a page into HTTPS - please help.

         

pokra

10:26 am on Jun 21, 2011 (gmt 0)

10+ Year Member



Hello. I have a very limited knowledge about .htaccess. I searched all over on how to turn a page into https. I found something and applied it to a site, but when I visit the page it got an "error of too much redirection". Like www.domain.com/test/test/test/test/test/.... and it goes on.

I am using Wordpress for the site and uploaded the original .htaccess to not have the problem. Please help me.

pokra

10:37 am on Jun 21, 2011 (gmt 0)

10+ Year Member



Or please if anyone could also send me a link on how turning http - https works. Right now I am reading every post:

[google.com ]

pokra

10:39 am on Jun 21, 2011 (gmt 0)

10+ Year Member



sorry this is the one: [google.com ]

g1smd

10:43 am on Jun 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Let's see your code.

There are hundreds of threads with example code in this forum. It is a question that is asked several times per month.

Use example.com to stop forum auto-linking.

pokra

10:54 am on Jun 21, 2011 (gmt 0)

10+ Year Member



Thank you for the reply g1smd! and I am very sorry if I am one of them that ask something like this. :(

Here is some of the codes I used. Since I don't know a lot about this subject, what I did was to search every code and apply them to the site. If that code won't work, I try another.

1.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} test
RewriteRule ^(.*)$ [domain.com...] [R,L]

2.
RewriteCond %{HTTPS} off
RewriteRule test [%{HTTP_HOST}%{REQUEST_URI}...] [L]

RewriteCond %{HTTPS} on
RewriteRule !test [%{HTTP_HOST}%{REQUEST_URI}...] [L]

3. This I found here in webmasterworld.

# Redirect HTTPS requests for non-SSL pages back to HTTP. (Note that shared objects
# such as images on both HTTP and HTTPS pages are excluded from this rule)
RewriteCond %{SERVER_PORT} =443
RewriteCond $1 !^test/test
RewriteCond $1 !\.(gif|jpe?g|png|ico|css|js)$
RewriteRule ^(.*)$ [%{HTTP_HOST}...] [R=301,L]
#
# Redirect HTTP requests for SSL checkout page to HTTPS
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^(test/test)$ [%{HTTP_HOST}...] [R=301,L]
#
# Redirect extensionless page requests to remove trailing slash
RewriteRule ^(test/test)/$ [%{HTTP_HOST}...] [R=301,L]
#

Again, thank you so much g1smd for your reply.

g1smd

11:22 am on Jun 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Use the Live HTTP Headers extension for Firefox to test the code. Try a range of http and https URLs, both www and non-www, that you do want to redirect and which you do not want to redirect and check you get the correct response for all of them.

Be aware that [R] generates a 302 redirect.

pokra

11:29 am on Jun 21, 2011 (gmt 0)

10+ Year Member



Thanks a lot g1smd! I will do that. Cheers!

pokra

11:31 am on Jun 21, 2011 (gmt 0)

10+ Year Member



May I know which of the 3 codes is the right one?

g1smd

12:02 pm on Jun 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The code that redirects some URLs to http and some to https is the right one.

You need both on most sites. It is also right that requests for images, CSS and JS are not redirected and can be served as http or as https. This avoids the "mixed protocol" security warnings.

pokra

12:55 pm on Jun 21, 2011 (gmt 0)

10+ Year Member



Thanks a lot! You are a great help!

pokra

9:19 pm on Jun 21, 2011 (gmt 0)

10+ Year Member



Hello again g1smd. I am very sorry but I have made a huge mistake. I have just learned that the server used in the site is not Apache but Nginx. I have found this when I compared the response headers using Live HTTP Headers extension for Firefox. That would explain why the code won't work on the site. I was really confused for the above code works when I tested them locally.

Again I am very sorry.

g1smd

9:24 pm on Jun 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It's an easy mistake to make. I can't help you with settings for Nginx, but you know where to look if you need help with Apache or IIS.

You might try asking in the *nix forum here at WebmasterWorld. Maybe there is a dedicated Nginx forum somewhere?

pokra

11:23 pm on Jun 21, 2011 (gmt 0)

10+ Year Member



I completely understand g1smd! No worries. :)

I think I have found the right ones for study about Nginx. A very interesting server for me. As always, thank you for your help.