Ways to get file directory trough .htaccess by utilizing RewriteRule ^(.*)$ ?id=$1 [L,QSA]?

If .htaccess is situated in http://localhost/some/dir/.htaccess and I am opening http://localhost/some/dir/here/I/use/RewriteRule/, the way i identify value /some/dir/ without needing RewriteBase and without manual adding %{DOCUMENT_ROOT}/some/dir/, like value localhost I recieve trough %{HTTP_HOST}?

If you don't use RewriteBase you have to tell mod-rewrite the actual Directory Root /var/ww/mysite/some/dir within the rewrite rule. RewriteBase would go ahead and take location url and map it towards the directory.

So you'll maybe finish track of

 RewriteRule /var/ww/mysite/some/dir/(.*)$ ?id=$1 [L,QSA]

And seeking to map some internal variables it might be

 RewriteRule %{DOCUMENT_ROOT}/some/dir/(.*)$ ?id=$1 [L,QSA]

But I am unsure, I rarely use mod_rewrite inshtaccess -- I favor Directory tags, and also the file path management could be different inshtaccess (auto removal and adding of directory prefixes). If you don't take action attempt to request Servfault, lots of admins other there.

Actualy Apache still doesn't have pathinfo($,PATHINFO_DIRNAME), function like has PHP.

The like now you will find solution on using %{REQUEST_URI}, such as this example:

RewriteRule ^(.+)/$ /path-dirname/$1 [R=301,L]

may totally reset with:

RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteRule ^.+/$ %1 [R=301,L]