Search code examples
apache.htaccessdocument-rootdirname

htaccess document_root dirname


is it possible to do this

RewriteRule robots.txt dirname(%{DOCUMENT_ROOT})/robots.php [L]

i need get parent folder of DOCUMENT_ROOT


Solution

  • You can't create a rewrite rule pointing to a target outside the document root in the context of a .htaccess file, so even if it were possible to find out the parent directory (which I doubt), it won't work.

    The only way around this that I know is creating a symbolic link that points to the correct robots.php file. It may even be possible to create a relative symbolic link pointing to ../robots.php, I'm not sure.