Forum Moderators: phranque

Message Too Old, No Replies

rewrite for specific page in joomla

SSL rewrite / url redirect

         

nservices

6:43 am on Jun 4, 2009 (gmt 0)

10+ Year Member



Hi,
how i can rewrite the page
[mysite.com...]
to [mysite.com...]
or to [mysite.com...] (this address work with SSL automatically

Thanks,
Nservices.

g1smd

9:21 am on Jun 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You cannot rewrite from http to https. A rewrite connects a URL request with an internal file.

In this case, it looks like you might need a redirect instead of a rewrite.

Check [google.com...] for some pointers to get started and post your best effort back here for discussion.

nservices

8:46 pm on Jun 4, 2009 (gmt 0)

10+ Year Member



redirect work well for index.php
in redirect 301 /index.php [mysite.com...]
but not work in:
in redirect 301 index.php?option=com_chronocontact&chronoformname=order [mysite.com...]

any idea ?

g1smd

11:23 pm on Jun 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Redirect cannot see parameters appended to a URL.

You will need to use RewriteRule for this redirect, with the [R=301,L] flag; as well as a RewriteCond that looks at QUERY_STRING too.

There are a large number of previous examples using these.

jdMorgan

11:34 pm on Jun 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use the redirect form of mod_rewrite, and check the query string using a RewriteCond:

Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{HTTP_HOST} =www.example.com
RewriteCond %{SERVER_PORT} !=443
RewriteCond %{QUERY_STRING} =option=com_chronocontact&chronoformname=form1
RewriteRule ^index\.php$ https://www.example.com/index.php [R=301,L]

This code is intended for use in example.com/.htaccess. It also assumes that all http and https requests resolve to that same directory, that no other mod-rewrite rules are present, and that only requests with that *exact* query string are to be redirected. If any of these assumptions are not true, you should tell us.

Note that query strings pass through mod_rewrite unchanged unless they are explicitly replaced in the substitution URL. It is therefore not necessary to mention the query string in the RewriteRule substitution in this case.

Jim

[edited by: jdMorgan at 1:24 pm (utc) on June 6, 2009]

nservices

7:50 am on Jun 6, 2009 (gmt 0)

10+ Year Member



Work, Thanks!
(but only without the line:
RewriteCond %{HTTP_HOST} =www\.mydomain\.co.uk
if i add this line, its not work.

Best Regards,
Nservices.

jdMorgan

1:26 pm on Jun 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes -- Sorry, I had several typos in that line. I fixed it above so that no-one else would have the same problem. Remove the backslashes from the pattern, as they should not be used with a literal string compare. They are only needed for regular-expressions compares.

Jim