Forum Moderators: phranque

Message Too Old, No Replies

Same RewriteRule Two Different Results

rewriterule

         

josequinonesii

9:36 pm on Nov 16, 2009 (gmt 0)

10+ Year Member



I'm using the following rules below and I'm trouble shooting but not getting and changes. Can someone be a fresh set of eyes and give me a nudge?

.htaccess file

RewriteCond %{HTTPS} !=on
RewriteRule ^/(.*) [%{SERVER_NAME}%{REQUEST_URI}...] [NC,R,L]

The following examples all use the above rule. The first one doesn't work. In the iframe like the others do but it does work without the IFRAME:

Doesn't Work:
http://www.example.com/support/social-media-lab-workshop-registration/

Works without Iframe:
[example.com...]

IFRAME CODE:
<iframe height="930" allowTransparency="true" frameborder="0" scrolling="vertical" style="width:100%;border:none" src="https://www.example.com/cc-process/formSML-Cart-GA.php"><a href="https://www.example.com/cc-process/formSML-Cart-GA.php" title="Our Online Payment System"><a></iframe>

EXAMPLES that work in and out of iframe:
[example.com...]

[example.com...]

[example.com...]

[edited by: jdMorgan at 12:50 am (utc) on Nov. 17, 2009]
[edit reason] example.com [/edit]

jdMorgan

12:57 am on Nov 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not sure what you mean by "doesn't work." It's the same as if we answered, "That's because it's broken"...

1) Be sure you completely flush (delete) your browser cache after changing any server-side code, in order to avoid seeing stale browser-cahced results.

2) .htaccess code will only affect requests which resolve to this server and to files in this .htaccess file's directory, and --only if "RewriteOptions inherit" is set-- in directories below this .htaccess file's directory.

Jim

josequinonesii

1:19 am on Nov 17, 2009 (gmt 0)

10+ Year Member



Doesn't work was simply to designate the example link not working compared to the others that do?

1) I tested in multple browser to ensure "it doesn't work"

2) All files for the ones that "do work" are in the same directory compared to the one that "doesn't work".

As I stated clearly, all the pages use the same rules and they are in the same directory on the same server.

josequinonesii

1:21 am on Nov 17, 2009 (gmt 0)

10+ Year Member



i guess you don't see anything wrong with the code since you gave my a "documentation-like" response.

jdMorgan

2:11 am on Nov 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, nothing wrong with that code, except for the unnecessary [NC] flag. I'd also suggest using [R=301] rather than just [R].

Unfortunately, neither of those minor issues has anything to do with the problem...

Jim

jdMorgan

2:40 am on Nov 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just a thought...

You might want to try


RewriteCond %{SERVER_PORT} !=443

instead of testing %{HTTPS} in case there's some context difference leaving the latter undefined in your failed cases.

Jim

josequinonesii

5:10 pm on Nov 17, 2009 (gmt 0)

10+ Year Member



Thanks for the suggestions Jim. I've applied the suggestions but with no luck to the page that does not apply httpS and keeps the http protocol. Everything else in the template is the same as I gone line by line and have found no differences outside the custom PHP segments of which no php is affecting/calling http references.

jdMorgan

5:31 pm on Nov 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One aspect of this which is unclear to me (because I don't use them) is the 'effect' that 'being in an iFrame' might have on the requested URL. You might want to dig into your server's raw access and error log files, and compare the URL requested (and the filepath that that URL gets resolved to) by the client outside the iFrame to the one (purportedly for the same URL) inside the iFrame.

Obviously, something somewhere is changing something about the request, which causes it to not match the pattern in the rule when "it doesn't work." It's also possible that the requested URL *would* match the rule, but that the rule is located in a server filepath which is not traversed when the request comes from an iFrame -- In other words, some other code or directive grabs the iFramed request and does something with it before your rule can run. This could be a higher-level .htaccess file, or a server config file, or even a 'wrapper script' if you use such.

Jim

josequinonesii

5:53 pm on Nov 17, 2009 (gmt 0)

10+ Year Member



There was nothing in the parent .htaccess and I hadn't seen anything in the error_log for that particular folder but I'll check the parent folder.

You're right, something somewhere is giving me gray hair :)

If I find anything and resolve I'll post.

Thanks again

josequinonesii

7:33 pm on Nov 17, 2009 (gmt 0)

10+ Year Member



Found no issues in the error logs.

The first thing in every one of the above examples includes this conditional in addition to the .htaccess file:

if($_SERVER["HTTPS"] != "on") {
header("HTTP/1.1 301 Moved Permanently");
header("Location: ["...] . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]);
exit();
}

josequinonesii

7:42 pm on Nov 17, 2009 (gmt 0)

10+ Year Member



will be checking cpanel settings next...

josequinonesii

8:08 pm on Nov 17, 2009 (gmt 0)

10+ Year Member



Ok,

after looking at the cpanel error log I found
[Tue Nov 17 15:01:27 2009] [error] [client 99.28.249.30] File does not exist: /home/#*$!x/public_html/cc-process/images/cmxform-divider.gif
[Tue Nov 17 15:01:24 2009] [error] [client 99.28.249.30] File does not exist: /home/#*$!x/public_html/cc-process/images/cmxform-fieldset.gif

I've correct the issue by creating the directory and places images there. Still did not correct the issue.

josequinonesii

8:53 pm on Nov 17, 2009 (gmt 0)

10+ Year Member



FOUND IT!

In the header of a theme within wordpress there was a hardcoded reference to force HTTPS for only specific files in addition to all the other references of rewriterule in .htaccess, the top of the php page, and confd

Anyway, thanks for your input.