htaccess question

[email protected] (Al)
Newsgroups php.general
Message-ID <[email protected]>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.