As an example, making use of the variable SCRIPT_FILENAME
we can get the requested file , but for this problem what is wanted is to get the directory where the file .htaccess
is located:
# Rewrite the url
<IfModule mod_rewrite.c>
RewriteEngine On
#DirectorySlash Off
RewriteBase /
# Redirect when the target isn't an existent file or directory
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^ /www/index.php [L]
</IfModule>
The idea is to replace www
with a variable so that when you change the file .htaccess
of location you do not need to edit it to change the reference.
In practical terms, and for this specific case, the code above is used within a folder that is in the root of the housing, that is, within public_html
.
The following rule:
RewriteRule ^ /www/index.php [L]
can be:
RewriteRule ^ /www2/index.php [L]
or
RewriteRule ^ /bubu/index.php [L]
Question
Is there any way to reference the directory where the .htaccess
file is, even if limited to the specific scenario indicated here?