Re: [PHP] htaccess question
[email protected] (Daniel Brown)
| Newsgroups | php.general |
|---|---|
| Message-ID | <CAD9cneNgTd-kwyn=8oA_hb3=xibRiVtnPUfvuAZC2N+v9=SWNQ@mail.gmail.com> |
On Tue, Apr 9, 2013 at 2:07 PM, Al <[email protected]> wrote: > I know it's not a php question, but I can't readily find the answer > elsewhere. > > I want to make this directive universal. Put htaccess file on any host in > any folder. > > This works > RewriteEngine On > > RewriteCond %{SERVER_PORT} !=443 > > RewriteRule ^(.*)$ https://www.foo.org/bar/$1 [R=301,L] #Here the foo.org > and /bar must be specified > > I want what is in effect > > RewriteRule ^(.*)$ https://{host_name}/{directory}/$1 [R=301,L] > > I can easily do this with php regex capturing the (host and dir) and then > rewriting the text string; but the Apache directives are not obvious. You were on the right track: RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] -- </Daniel P. Brown> Network Infrastructure Manager http://www.php.net/