homepage Welcome to WebmasterWorld Guest from 54.227.12.219
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
http to https
http to https redirection
dartsuresh




msg:4500020
 5:27 am on Sep 26, 2012 (gmt 0)

Hi,
i need a help.already we have mode rewrite rule RewriteRule ^(.*).html$ index.php?set=$1
this rule change html url to php now in this i need to add a condition https redirect how with this existing condition can i add new feature.

I tried to changed htaccess file but after my change my site not working properly.
My old htaccess working correctly new one not working.

my project is zend frame work plzz help

Old one
RewriteEngine On
RewriteRule ^(.*).html$ index.php?set=$1

New One
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^(.*).html$ index.php?set=$1

 

dartsuresh




msg:4500221
 2:27 pm on Sep 26, 2012 (gmt 0)

anybody help me to out this issue plzz

phranque




msg:4500376
 8:44 pm on Sep 26, 2012 (gmt 0)

not working

what HTTP Response did you get?
(status code and perhaps a Location: header)

dartsuresh




msg:4500431
 11:46 pm on Sep 26, 2012 (gmt 0)

thanx for u r replay this was i got

https://example.com/index.php?set=https://example.com/home/login.html/login

phranque




msg:4500463
 3:35 am on Sep 27, 2012 (gmt 0)

install the Live HTTP Headers add-on for firefox and you will be able to observe and then report the status code chain.

dartsuresh




msg:4500518
 9:09 am on Sep 27, 2012 (gmt 0)

Thanx u r advice
this will i got when i try to login submit

http://example.com/home/login.html

POST /home/login.html HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cookie: PPv82868=ti%3D1347453695%3Brc%3D3; PHPSESSID=b10qi7p61ndjh5k1rf1ab67oo0
Content-Type: application/x-www-form-urlencoded
Content-Length: 53
user_id=admin&password=admin&language=EN&submit=
HTTP/1.1 301 Moved Permanently
Date: Thu, 27 Sep 2012 09:13:37 GMT
Server: Apache
Location: https://example.com/home/login.html
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 206
Connection: close
Content-Type: text/html; charset=iso-8859-1
----------------------------------------------------------
https://example.com/home/login.html

GET /home/login.html HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cookie: PPv82868=ti%3D1347453695%3Brc%3D3; PHPSESSID=b10qi7p61ndjh5k1rf1ab67oo0

HTTP/1.1 200 OK
Date: Thu, 27 Sep 2012 09:13:39 GMT
Server: Apache
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 1194
Connection: close
Content-Type: text/html
----------------------------------------------------------


can u get any clue from this

swa66




msg:4500544
 10:25 am on Sep 27, 2012 (gmt 0)

Why do you first POST to the http website ?

dartsuresh




msg:4500557
 10:39 am on Sep 27, 2012 (gmt 0)

That form action of my login page
<form id="homepage-login-form" action="http://example.com/home/login.html" method="post">
<p>
<label for="user_id">USER-ID</label>
<input name="user_id" type="text" />
</p>
<p>
<label for="password">PASSWORD</label>
<input name="password" type="password" />
</p>
<p>
<label for="language">LANGUAGE</label>
<select name="language">
<option value="EN">English</option>
<option value="NL">Netherlands</option>
</select>
</p>
<p id="remember-me">
<label for="remember_me">REMEMBER ME</label>
<input name="remember_me" type="checkbox" />
</p>
<p>
<input id="login-btn" type="submit" value="" name="submit" />
</p>
</form>


This url what exact doing with my old rewrite rule
http://example.com/home/login.html
RewriteEngine On
RewriteRule ^(.*).html$ index.php?set=$1


is i have template and controller for this
controler->home.php->login()
template->home.html

controller did the function and display the template.

i need this same functionality with https featurethats y i try new rewrite rule
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^(.*).html$ index.php?set=$1


thanks in advance

swa66




msg:4500684
 3:39 pm on Sep 27, 2012 (gmt 0)

You cannot 301 redirect a POST, Only GET and HEAD are allowed.

Ref: [w3.org...]
The action required MAY be carried out by the user agent without interaction with the user if and only if the method used in the second request is GET or HEAD

iow. Browsers are not allowed without user interaction to do the POST again on a redirected URL.

Simplest solution: add the https in your form action.

swa66




msg:4500696
 3:52 pm on Sep 27, 2012 (gmt 0)

Maybe that -considering more novice users might read this as well- we should elaborate a bit:

A POST sends data to the server, it is intended that the server does process that data ("do some work"). The purpose of a POST in not only to hide the data from the URL (in case of a login this is important) but also to make sure the browser doesn't resend that data for whatever whim it has [the concept is that a GET or HEAD are that repeating them can't do damage, while a POST could do damage if repeated.

Now from any scripting language, it is common to send a redirect after you do the processing: that redirect will be followed, but the browser will NOT follow it with a POST request and send the data again, instead it'll send a GET request only. This is intended behaviour and demanded by the standards.

However, this does mean that you cannot redirect a POST and without processing the data expect the browser to do another POST and resend the data again.

dartsuresh




msg:4500743
 5:06 pm on Sep 27, 2012 (gmt 0)

without rewrite how can i change automatically http to https

swa66




msg:4500750
 5:11 pm on Sep 27, 2012 (gmt 0)

change
<form id="homepage-login-form" action="http://example.com/home/login.html" method="post">

to
<form id="homepage-login-form" action="https://example.com/home/login.html" method="post">

dartsuresh




msg:4500767
 5:55 pm on Sep 27, 2012 (gmt 0)

Ok, If i used like this how can i change automatically rewrite http to https if uses open my site http://example.com. Thats y i used the rewrite condition
RewriteCond %{HTTPS} !=on



Here i explain once again my requirement.
I already have a rewrite rule in .htaccess. My old rule replaces all html extensions with php. My .htaccess:
RewriteEngine On
RewriteRule ^(.*).html$ index.php?set=$1

Now we have a SSL so now I want to redirct all url http to https, If user try open my site http://example.com i need to automatically change http to https,thats y i changed my old rule
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule ^(.*).html$ index.php?set=$1

after this my site not working proberly. How can i change without affecting old rule.

g1smd




msg:4500782
 6:24 pm on Sep 27, 2012 (gmt 0)

Why are you replacing .html extensions with .php? You do not need to change the extension in the URL when you change the extension of the file inside the server. This is another use for rewrites.

dartsuresh




msg:4500792
 6:52 pm on Sep 27, 2012 (gmt 0)

That is client requirement.
He like to show url in browser with html extention. we manipulate url with controller and templates internally.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved