Hi Nicolaas,
I haven't used "RewriteCond %{HTTPS} on" before, so I am unsure that it
works. But you could try using the ports.
RewriteCond %{SERVER_PORT} ^20445$
RewriteRule !^search-results/view/ http://%{SERVER_NAME}%{REQUEST_URI}
[R=301,NC,L]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^search-results/view/ http://%{SERVER_NAME}:20445%{REQUEST_URI}
[R=301,NC,L]
Might help to use 302 when testing, either that or flush the browsers cache.
I think HTTP_HOST might include the port e.g. ":443" at the end, which is
maybe why it wasn't working.
Good luck.
Cam
On Thu, Oct 8, 2009 at 7:07 PM, nicolaas <[email protected]> wrote:
>
> thank you all for your answers. It is not making more sense to me
> unfortunately. The thing is I am not so keen just to copy something
> and hope it works. I am trying to understand what is wrong with my
> code.
>
> Here is my code with explanations:
>
>
> ## basic stuff
> <IfModule mod_dir.c>
> DirectorySlash Off
> </IfModule>
>
> ## basic stuff
> RewriteEngine On
> RewriteBase /
>
> ## ----------- start error prone part
> ## if HTTPS is ON
> #RewriteCond %{HTTPS} on
>
> ## rewrite to normal site
> #RewriteRule !^search-results/view/(.*) http://%{HTTP_HOST}%{REQUEST_URI}
> [R=301,NC,L]
> ## ----------- end error prone part
>
> ## if HTTPS is OFF
> RewriteCond %{HTTPS} off
>
> ## and URL starts wtih search-results/view then rewrite to HTTPS with
> special port
> RewriteRule ^search-results/view/(.*) https://
> %{HTTP_HOST}:20445%{REQUEST_URI}
> [R=301,NC,L]
>
> ## I always use the stuff below for my CMS, should work fine!
> ## however, I am adding it here as one could influence the other
> RewriteCond %{REQUEST_URI} !(\.gif)|(\.html)|(\.jpg)|(\.png)|(\.css)|
> (\.js)|(\.php)$
> RewriteCond %{REQUEST_URI} ^(.*)$
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
> >
>
--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---