You cannot rewrite on paths that are outside the root of the document for security reasons. In fact, this should be avoided because it is not a good practice.
In any case, in order to answer your question, a workaround can create a symbolic link in the root of your document that points to the target / parent directory, but you must protect it from direct access.
Let me give you an example. Suppose our document root is /var/www/project1 and what you want to rewrite to /var/www/project2/target.php
Then you need to create a symbolic link inside /var/www/project1 that points to /var/www/project2 with the name (for example) p2 .
This should be your /var/www/project1/.htaccess file:
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_URI} /hello/world RewriteRule ^(.*)$ p2/target.php [QSA,L] # p2 is the symlink name! </IfModule>
source share