mvccore / ext-request-apachedpi
MvcCore - Extension - Request - Apache DPI - request BasePath property correction for applications using Apache .htaccess [DPI] flag.
v4.3.1
2017-12-17 19:25 UTC
Requires
- php: >=5.3.0
- mvccore/mvccore: ^4.3.1
Requires (Dev)
- php: >=5.3.0
- mvccore/mvccore: ~4.3.1@dev
README
MvcCore Extension - Request - Apache DPI
MvcCore Request extension to correct request BasePath property - for applications using Apache .htaccess [DPI] flag.
Installation
composer require mvccore/ext-request-apachedpi
Usage
I you are using more PHP applications with more different domains in one webhosting space, you always need to route every request into different index .htaccess file.
.htaccess in webhosting root:
# disable directory listing Options -Indexes # mod_rewrite <IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=REDIRECT_PATH:] # If directory with HTTP_HOST name exists in domains directory, # dispatch request into this webhosting directory with requested application: RewriteCond %{HTTP_HOST} ^(.*)$ RewriteCond %{DOCUMENT_ROOT}/domains/%1 -d RewriteRule (.*) domains/%1/$1 [DPI,QSA,E=REDIRECT_PATH:/domains/%1,L] </IfModule>
.htaccess in application root (classic):
# disable directory listing Options -Indexes # mod_rewrite <IfModule mod_rewrite.c> RewriteEngine On # forbid the direct access to app directories (eg. config-files, ...) RewriteRule ^App/.*$ / [F,L] RewriteRule ^vendor/.*$ / [F,L] # basic zend-framework setup see: http://framework.zend.com/manual/en/zend.controller.html RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^(.*)$ $1 [NC,L] RewriteRule ^.*$ index.php [NC,L] </IfModule>
PHP application Bootstrap.php
Put this patching code in very beginning of your application:
\MvcCore::GetInstance()->SetRequestClass(\MvcCore\Ext\Request\ApacheDpi::class);