mvccore / ext-request-apachedpi
MvcCore - 扩展 - 请求 - Apache DPI - 修正使用 Apache .htaccess [DPI] 标志的应用程序的请求 BasePath 属性。
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 扩展 - 请求 - Apache DPI
MvcCore 请求扩展用于修正请求 BasePath 属性 - 用于使用 Apache .htaccess [DPI] 标志 的应用程序。
安装
composer require mvccore/ext-request-apachedpi
使用方法
如果你在同一个网络托管空间中使用更多不同域的 PHP 应用程序,你总是需要将每个请求路由到不同的索引 .htaccess 文件。
网络托管根目录下的 .htaccess
# 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(经典版)
# 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 应用程序的 Bootstrap.php
将此修复代码放在应用程序开头部分
\MvcCore::GetInstance()->SetRequestClass(\MvcCore\Ext\Request\ApacheDpi::class);