[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: best pactice - apache, rewrite, ssl, virtualhost or .htaccess



On Mon, Jul 31, 2006 at 10:24:41PM +0200, Ernst-Magne Vindal wrote:
> 
> On Mon, July 31, 2006 19:43, Casey T. Deccio said:
> > On Mon, 2006-07-31 at 14:41 +0200, Ernst-Magne Vindal wrote:
> >> I have tryed to redir with .htaccess file and by config virtualhosts. Both
> >> seams
> >> to work ok, but will be happy for some comments for best practice.
> >
> > According to:
> > http://httpd.apache.org/docs/2.0/howto/htaccess.html#when
> >
> > <quote>
> > .htaccess files should be used in a case where the content providers
> > need to make configuration changes to the server on a per-directory
> > basis, but do not have root access on the server system. In the event
> > that the server administrator is not willing to make frequent
> > configuration changes, it might be desirable to permit individual users
> > to make these changes in .htaccess files for themselves. This is
> > particularly true, for example, in cases where ISPs are hosting multiple
> > user sites on a single machine, and want their users to be able to alter
> > their configuration.
> >
> > However, in general, use of .htaccess files should be avoided when
> > possible. Any configuration that you would consider putting in
> > a .htaccess file, can just as effectively be made in a <Directory>
> > section in your main server configuration file.
> > </quote>
> >
> > Casey
> >
> 
> Thanks all, tryed all but no go yet....
> That is redirect is ofcause OK, its just the rewrite of url I can't get to
> work...anyhow, googleing on
> 
> and using <Directory> section:)
> thanks
> 
> -- 
> /ernst-magne
> 
> If you can't explain it simply, you don't understand it well enough.
> (Albert Einstein)

Hi,

According to the Apache documentation the [R] flag is to prefix the
substitution with http://thishost[:thisport]/ to force an external
redirection.

Also from the mod_rewrite documentation:
"When you prefix a substitution field with http://thishost[:thisport],
mod_rewrite will automatically strip that out. This auto-reduction on
URLs with an implicit external redirect is most useful in combination
with a mapping-function which generates the hostname part.

Remember: An unconditional external redirect to your own server will
not work with the prefix http://thishost because of this feature. To
achieve such a self-redirect, you have to use the R-flag."

I.e if you specify:
RewriteEngine On
RewriteRule ^/(.*)$ https://webmail.yourdomain.com/$1 [R,NC]

then anybody requesting http://webmail.yourdomain.com/anything should be
redirected to the https://webmail.yourdomain.com/anything.

For more complex rewriting have a look at
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

Simo
-- 
:r ~/.signature

Attachment: signature.asc
Description: Digital signature


Reply to: