You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Bryan Richardson <bt...@gmail.com> on 2007/12/16 20:45:14 UTC

[users@httpd] Help w/ Rewrite

Hello all,

I have a directory on my webserver (say http://localhost/foo/) who's
subdirectories (say bar/ and cha/) I want to only be available via SSL (
https://localhost/foo/bar/ % https://localhost/foo/cha/).  I have the
following .htaccess in my foo/ directory, but it's not working.  I assume
the rewrite just isn't getting called on because I don't get any errors or
anything.  mod_rewrite is enabled, and AllowOveride is set to All for my
root directory.  I've tried both ^(.*)$ and /^(.*)$ for the rewrite rule.
Any suggestions?  Thanks! -- BTR

#### .htaccess file in foo/ directory ####

RewriteCond %{SERVER_PORT} !^443$
RewriteRule /^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

Re: [users@httpd] Help w/ Rewrite

Posted by Vincent Bray <no...@gmail.com>.
On 16/12/2007, Bryan Richardson <bt...@gmail.com> wrote:
> Thanks. I took a look at the Wiki links you provided, and I think I'll
> try using Redirect instead. Any hints as to how I would use Redirect
> in this situation?

Redirect is a simpler solution but will only work in the main server
config. If you're able to do that then you should just drop htaccess
in general. The idea is that because there  are always two vhosts (one
ssl, one not) then you just put Redirect in one of them.

> Another question: is the RewriteEngine directive site-wide or per
> directory? Also, if I say RewriteEngine On in a directory that I also
> say AllowOverride All, do I have to say RewriteEngine On again in the
> .htaccess file?

I don't know. Sorry!

-- 
noodl

---------------------------------------------------------------------
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] Help w/ Rewrite

Posted by Bryan Richardson <bt...@gmail.com>.
Thanks. I took a look at the Wiki links you provided, and I think I'll
try using Redirect instead. Any hints as to how I would use Redirect
in this situation?

Another question: is the RewriteEngine directive site-wide or per
directory? Also, if I say RewriteEngine On in a directory that I also
say AllowOverride All, do I have to say RewriteEngine On again in the
.htaccess file?

Thanks again for the help! -- BTR

On 12/16/07, Vincent Bray <no...@gmail.com> wrote:
> On 16/12/2007, Bryan Richardson <bt...@gmail.com> wrote:
> [snip]
> > root directory.  I've tried both ^(.*)$ and /^(.*)$ for the rewrite rule.
> > Any suggestions?  Thanks! -- BTR
>
> The first of those should work but the second not (it's not really a
> valid regex as ^ mid-string doesn't have a special meaning, and in
> htaccess there's no leading slash). Try these wiki pages:
>
> http://wiki.apache.org/httpd/RewriteHtaccessIgnored
> http://wiki.apache.org/httpd/RewriteContext
> http://wiki.apache.org/httpd/RewriteHTTPToHTTPS
>
> --
> noodl
>
> ---------------------------------------------------------------------
> 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
>
>

---------------------------------------------------------------------
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] Help w/ Rewrite

Posted by Vincent Bray <no...@gmail.com>.
On 16/12/2007, Bryan Richardson <bt...@gmail.com> wrote:
[snip]
> root directory.  I've tried both ^(.*)$ and /^(.*)$ for the rewrite rule.
> Any suggestions?  Thanks! -- BTR

The first of those should work but the second not (it's not really a
valid regex as ^ mid-string doesn't have a special meaning, and in
htaccess there's no leading slash). Try these wiki pages:

http://wiki.apache.org/httpd/RewriteHtaccessIgnored
http://wiki.apache.org/httpd/RewriteContext
http://wiki.apache.org/httpd/RewriteHTTPToHTTPS

-- 
noodl

---------------------------------------------------------------------
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