How to reference the current board

16

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?

    
asked by anonymous 03.12.2014 / 21:22

2 answers

0

On UNIX systems (Linux, BSD, etc.) you use ./ to refer to the current directory.

    
23.04.2015 / 07:56
0

You can use regex within .htaccess, which would look something like this:

RewriteRule ^ (\.+)?\/index.php [L]

In the expression I'm defining that anything can exist in any quantity before

.

    
22.07.2017 / 02:46