Welcome to WebmasterWorld Guest from 23.20.230.24

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

http to https

http to https redirection

     
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 ^ [%{HTTP_HOST}%{REQUEST_URI}...] [L,R=301]
RewriteRule ^(.*).html$ index.php?set=$1
2:27 pm on Sep 26, 2012 (gmt 0)



anybody help me to out this issue plzz
8:44 pm on Sep 26, 2012 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



not working

what HTTP Response did you get?
(status code and perhaps a Location: header)
11:46 pm on Sep 26, 2012 (gmt 0)



thanx for u r replay this was i got

[example.com...]
3:35 am on Sep 27, 2012 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



install the Live HTTP Headers add-on for firefox and you will be able to observe and then report the status code chain.
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: [example.com...]
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 206
Connection: close
Content-Type: text/html; charset=iso-8859-1
----------------------------------------------------------
[example.com...]

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
10:25 am on Sep 27, 2012 (gmt 0)

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Why do you first POST to the http website ?
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 ^ [%{HTTP_HOST}%{REQUEST_URI}...] [L,R=301]
RewriteRule ^(.*).html$ index.php?set=$1


thanks in advance
3:39 pm on Sep 27, 2012 (gmt 0)

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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.
3:52 pm on Sep 27, 2012 (gmt 0)

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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.
5:06 pm on Sep 27, 2012 (gmt 0)



without rewrite how can i change automatically http to https
5:11 pm on Sep 27, 2012 (gmt 0)

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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">
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 ^ [%{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.
6:24 pm on Sep 27, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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.
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.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month