LLLLLLL Posted May 7, 2012 Share Posted May 7, 2012 This one requires lots of up front information: [*]I have a page, for this example that I will call page.php. It takes get parameters, and for this example I'll call the parameter "step". So I have a URL like this: page.php?step=1 [*]This page has a form with an action of page.php?step=1. [*]The code on the page validates the posting information. If the information is bad, it returns the user to page.php?step=1; if it is good, it takes the user to page.php?step=2 via header( "location:page.php?step=2" ). So redirection is done by relative path, not full URLs. This all works as expected. Now what I've done is set .htaccess to be HTTPS for this page, via this code: # Turn SSL on for payments RewriteCond %{HTTPS} off RewriteCond %{SCRIPT_FILENAME} \/page\.php [NC] RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] This works (initially). However, once you try to post the form, it just redirects back to the step=1 version of the page. I really don't know how or why that would be. I'm not sure how else I can explain this or what other information you may have. But it's frustrating to not get a page working in HTTPS that works in HTTP. Very odd. Any suggestions? (I don't even really know the best location to figure out when/why it's redirecting back to the original page.) Quote Link to comment https://forums.phpfreaks.com/topic/262212-code-works-htaccess-modifications-work-they-dont-work-together/ Share on other sites More sharing options...
xyph Posted May 7, 2012 Share Posted May 7, 2012 It's hard to say what's going on here, but when you specify a relative URI in your 'location' header, you're breaking spec. When you break spec, you're hoping the browser's been coded in such a way that it will do what you desire. Using redirects makes debugging very hard, unless you're also passing error codes along with it. You should comment out your redirect, and dump your data instead. Make sure the data is what you'd expect it to be. Quote Link to comment https://forums.phpfreaks.com/topic/262212-code-works-htaccess-modifications-work-they-dont-work-together/#findComment-1343779 Share on other sites More sharing options...
LLLLLLL Posted May 7, 2012 Author Share Posted May 7, 2012 I don't understand why I'm breaking spec by using header( "location:abcd" ). Can you explain? Which redirect do you think I should comment out? As explained before, the code works just fine. The only error is when .htaccess is then configured to ensure pages are HTTPS. What do you mean "dump the data instead"? Quote Link to comment https://forums.phpfreaks.com/topic/262212-code-works-htaccess-modifications-work-they-dont-work-together/#findComment-1343785 Share on other sites More sharing options...
LLLLLLL Posted May 9, 2012 Author Share Posted May 9, 2012 Actually I see now that the $_POST has nothing in it. Is the mod_rewrite eliminating the post on redirect? Quote Link to comment https://forums.phpfreaks.com/topic/262212-code-works-htaccess-modifications-work-they-dont-work-together/#findComment-1344127 Share on other sites More sharing options...
LLLLLLL Posted May 9, 2012 Author Share Posted May 9, 2012 Now that I'm closer to a solution, I'm finding exactly what's going on. Closing this topic and opened a new one: http://www.phpfreaks.com/forums/index.php?topic=359062.0 Quote Link to comment https://forums.phpfreaks.com/topic/262212-code-works-htaccess-modifications-work-they-dont-work-together/#findComment-1344135 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.