Welcome to WebmasterWorld Guest from 54.158.36.59

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

HTTPS to HTTPS rewrite (mind the S on both sides!)

using .htaccess to rewrite HTTPS requests

     
8:27 pm on Oct 12, 2012 (gmt 0)



I know this overall topic has been beaten to death but please read the problem carefully first. After hours of Googling I am giving up. I have found things that are close but not IT

PROBLEM: I need to rewrite (mind the protocol!)
HTTPS://foo.com/user/show.json
to
HTTPS://foo.com/index?my_tag=user/show.json

I can do this easily if I am using HTTP, for example, via .htaccess and mode rewrite

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php?my_tag=/$1 [L,QSA]


This WORKS in HTTP. It is IGNORED if I use it on an HTTPS folder and I get a 404 not found for [foo.com...] indicating that the rewrite never happened.

Please assume:
1) http.conf uses VirtualHost for port 80 and it has been working for years
2) ssl.conf is configured and it works for documents that need no redirect. For example, assume I drop document hello_world.php in the HTTPS folder, I can open [foo.com...] without problems (do note that this confirms that the rewrite has been ignored!)
3) I have read on the Apache documentation that mod_ssl will take care of unwrapping the HTTPS header and expose the HTTP header (which is what I am counting on) but it does not appear to be happening.

Help please.

running:
CentOS
Apache2
OpenSSL 0.9.8e
PHP 5.2.17
9:16 pm on Oct 12, 2012 (gmt 0)

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



1. Explain what this bit of code is supposed to match...

\?*$


2. A rewrite cannot rewrite https to https. "https to https" implies two URLs. A rewrite matches a URL request to an internal filepath inside the server. The protocol only has meaning in a URL out there on the web. It has no meaning in file paths inside the server.

3. A redirect redirects requests for one URL to another URL. In that case, both items do have an associated protocol. A RewriteRule with the [R] flag creates a redirect.
3:29 pm on Oct 14, 2012 (gmt 0)



1) I suppose it is redundant, please ignore
2) yes, I misspoke. Same difference, the problem still stands
3) got it, this is not my case. It is a rewrite to a local file.

The problem still stands. Have you have ever successfully rewrote an HTTPS request, please?
5:08 pm on Oct 14, 2012 (gmt 0)

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



The rule needs to sit in the root folder of wherever the https requests resolve to inside your server. Sometimes this is a different internal location to where http requests resolve to.
9:32 pm on Oct 14, 2012 (gmt 0)



Ah! *That* I did not know. Let me try to fix it with that in mind...
AWESOME, it works! THANK YOU!

To recap, if you need to use a rewrite rule in an HTTPS the rule must be at the root level. So if you use an .htaccess file, make sure it is placed in the root folder of your HTTPS container

Thank you guys, you rock!
 

Featured Threads

Hot Threads This Week

Hot Threads This Month