You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Steve Finkelstein <sf...@stevefink.net> on 2008/02/22 23:34:58 UTC

[users@httpd] Yay for mod_rewrite woes.

This is a very rudimentary concept and is typically done in a cookie
cutter fashion. However, I can't seem to recall the proper
syntax/conditions to get it to function as required.

Essentially I need to enable SSL in one URL and one URL only, one that
ends in login.php. So I wrote a rule like this:

  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteRule ^/login.php$ https://foo/login.php [R,L]

Works great.

Now in the SSL virtualHost, I want it to redirect to a non-SSL version
of the site if the URL doesn't end in login.php.

  RewriteEngine On
  RewriteRule !^/login.php$ http://%{SERVER_NAME}


This was working great except for one issue. It completely breaks all
images, CSS, JavaScript, and other goodies. Is there a possible way to
exclude those also or perhaps a more appropriate way to rewrite my
second batch of rules for the SSL Vhost?

Cheers,

/sf

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


[users@httpd] Re: Yay for mod_rewrite woes.

Posted by Steve Finkelstein <sf...@stevefink.net>.
Thanks Joshua. I figured what I was doing is inefficient and there
might be a better "algorithm" to lazy trigger the Rewrite versus
checking every single request. But since it's just one particular page
where this will be in effect, I'm not as concerned.

Cheers,

/sf

On 2/22/08, Steve Finkelstein <sf...@stevefink.net> wrote:
> This is a very rudimentary concept and is typically done in a cookie
>  cutter fashion. However, I can't seem to recall the proper
>  syntax/conditions to get it to function as required.
>
>  Essentially I need to enable SSL in one URL and one URL only, one that
>  ends in login.php. So I wrote a rule like this:
>
>   RewriteEngine On
>   RewriteCond %{HTTPS} !=on
>   RewriteRule ^/login.php$ https://foo/login.php [R,L]
>
>  Works great.
>
>  Now in the SSL virtualHost, I want it to redirect to a non-SSL version
>  of the site if the URL doesn't end in login.php.
>
>   RewriteEngine On
>   RewriteRule !^/login.php$ http://%{SERVER_NAME}
>
>
>  This was working great except for one issue. It completely breaks all
>  images, CSS, JavaScript, and other goodies. Is there a possible way to
>  exclude those also or perhaps a more appropriate way to rewrite my
>  second batch of rules for the SSL Vhost?
>
>  Cheers,
>
>
>  /sf
>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Yay for mod_rewrite woes.

Posted by Joshua Slive <jo...@slive.ca>.
On Fri, Feb 22, 2008 at 5:34 PM, Steve Finkelstein <sf...@stevefink.net> wrote:

>   RewriteEngine On
>   RewriteRule !^/login.php$ http://%{SERVER_NAME}
>
>
>  This was working great except for one issue. It completely breaks all
>  images, CSS, JavaScript, and other goodies. Is there a possible way to
>  exclude those also or perhaps a more appropriate way to rewrite my
>  second batch of rules for the SSL Vhost?

BEFORE the existing rewriterule, include other rewriterules to stop
processing on the files you want excluded:
RewriteRule \.(css|js|jpg) - [L]

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org