【发布时间】:2015-08-20 18:13:03
【问题描述】:
我有以下文件夹逻辑:
.htaccess
index.php
composer.json
(etc. with all processing files)
public/
.htaccess
design/
files/
(etc. with all static files)
在 .htaccess 中包含以下内容:
(.htaccess:)
RewriteEngine on
RewriteRule ^(.*)$ public/$1 [L]
(public/.htaccess)
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
第一个 .htaccess 在 MAMP 上进行开发时很有用,而在生产中不需要请求,因为大多数网站直接为公共文件夹提供服务。
与public/index.php 文件与include '../index.php'; 相比,此请求的原因是,例如,Slim 使用$_SERVER['PHP_SELF'] 会通过强制 /public 进入 url 来破坏路由。 One dirty way to solve this涉及更改vendor/slim/slim文件夹中的一个文件,应该是比较大的算了。
【问题讨论】:
标签: php apache .htaccess mod-rewrite slim