Your rewrite rule is a bit long, but there is a way to do what you are wanting:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteRule ^.*/css/(.*)$ css/$1
RewriteRule ^.*/images/(.*)$ images/$1
RewriteRule ^.*/js/(.*)$ js/$1
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

The way this would operate is as follows:

1. If the site is not https, then immediately redirect to https
2. If the request is for css, images, or javascript, remap the request
relative to the directory .htaccess is located.
3. If the request is for a valid file, symlink, or directory, open
that requested file, symlink, or directory, respectively.
4. Otherwise, route the request through index.php

What this allows me to do (especially step 2) is that I can define my
css, images, or javascript URLs relatively instead of absolutely. e.g.
I don't have to use <img src="/img/image.jpg" /> I can do <img
src="img/image.jpg" /> and it should work regardless of the request
and regardless of whether the application is installed at the root of
a web site (www.chrisweldon.net/) or in a subfolder
(www.chrisweldon.net/application).

You'll of course need to addon to mine to check for other media
content that you are checking for (xml, avi, etc.), but the premise
remains the same.
--
Chris Weldon

On Mon, Jan 26, 2009 at 7:24 PM, spaceage <[email protected]> wrote:
>
> I'm somewhat new to mod_rewrite and am hoping somebody here has already
> solved this problem.
>
> I use an .htaccess in my root dir as follows:
>
> RewriteEngine on
> RewriteRule !\.(js|ico|gif|jpg|png|css|swf|xml|avi|flv|mov|mp3|wav|pdf)$
> index.php
>
> I want to add another condition which requires/forwards to https for any
> request which has a URI of /checkout.
>
> I have full access to the apache server, so I can insert any directives
> necessary...
>
> Is it possible to chain the two conditions (the one I am running for the
> front controller above + the new /checkout forward to https) in the
> .htaccess file, or does one (or both) of the conditions need to be in a
> <Directory> or <VirtualHost> block?  Or maybe a <Location> block for
> /checkout?
>
> TIA!
> --
> View this message in context: 
> http://www.nabble.com/mod_rewrite-and-SSL-tp21677891p21677891.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>



-- 
Christopher Weldon
http://chrisweldon.net
[email protected]

Reply via email to