Forum Moderators: phranque

Message Too Old, No Replies

Single Page http => https rewrite /redirect

         

jomoweb

7:56 pm on Sep 2, 2008 (gmt 0)

10+ Year Member



Hi, I have a very simple payment system that resides on one page only in a CMS (dynamic URLS). I am trying to make it so htaccess will redirect the user to the SSL version of the page. Basically, I would like it to go

From here:
http://example.com/index.php?page=pay

to:
[example.com...]

I've tried a couple basic expressions like:

RewriteRule ^index.php?page=pay$

But the rule seems to hang up at the "=" sign... tried to escape that with /, but that did not work.

jdMorgan

12:19 am on Sep 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll need to test the query string separately, using a RewriteCond to examine %{QUERY_STRING}

You will also need another RewriteCond to check %{SERVER_PORT} for NOT 443 in order to prevent this rule from being applied to requests that *are* made on https -- resulting in an infinite loop.

Finally, your rule must have a destination URL and some flags. It should look like this:


RewriteRule ^(index\.php)?$ https://example.com/ [R=301,L]

As shown it will redirect requests for http://example.com/?page=pay or example.com/index.php?page=pay to [example.com...] -- assuming that you code the RewriteConds correctly.

Links to the mod_rewrite documentation, a regular-expressions tutorial, and other resources are available in our Forum Charter.

Jim