I need to get dynamically the current directory in which my .htaccess file is located. Is that possible ? (A variable maybe ?).
Something like : %{SCRIPT_FILENAME}
Thank you in advance.
EDIT : If with regular expressions ? how should it look like ?
Actually Apache still does not have pathinfo($,PATHINFO_DIRNAME) function like PHP does.
So on, there have been solutions based on the usage of %{REQUEST_URI}, like this example:
RewriteRule ^(.+)/$ /path-dirname/$1 [R=301,L]
Regarding your issue, this may work for you:
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteRule ^.+/$ %1 [R=301,L]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With