php - How to detect root folder in URI when using apache mod_alias and mod_rewrite? -
how detect root folder in uri when using apache mod_alias , mod_rewrite?
i have website running on sub folder in of document root example /var/www/this/an/other/dir in folder have .ht_access file mod_rewrite rules redirect index.php
# nothing if file (s), link (l) or (d) exists rewritecond %{request_filename} -s [or] rewritecond %{request_filename} -l [or] rewritecond %{request_filename} -d rewriterule ^.*$ - [nc,l] # redirect else index.php rewriterule ^.*$ index.php [e=port:%{server_port},nc,l]`
i have set alias easy access
alias /foo /var/www/this/an/other/dir
now when go address http://host.com/foo/bar/ how can detect /foo root folder of uri?
easiest way set env variable directly within apache:
setenv aliasroot /foo
you can access through $_env
superglobal:
$root = $_env['aliasroot'];
i don't think there reliable way in pure php.
Comments
Post a Comment