homepage Welcome to WebmasterWorld Guest from 54.226.80.196
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
HTTPS to HTTPS rewrite (mind the S on both sides!)
using .htaccess to rewrite HTTPS requests
amariotti




msg:4507599
 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 HTTPS://foo.com/user/show 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 https://foo.com/hello_world 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

 

g1smd




msg:4507619
 9:16 pm on Oct 12, 2012 (gmt 0)

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.

amariotti




msg:4507959
 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?

g1smd




msg:4507975
 5:08 pm on Oct 14, 2012 (gmt 0)

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.

amariotti




msg:4508013
 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!

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