【发布时间】:2013-09-12 20:26:49
【问题描述】:
我有一个 FuelPHP 应用程序,我正在尝试设置它以扩展现有网站(我们称之为 example.com)。 FuelPHP 安装在DocumentRoot 中名为listings 的目录中。但是,应用程序的主文件index.php 位于listings 的子目录public,因此index.php 文件的实际路径是<DocumentRoot>/listings/public/index.php。应用程序的静态资产(JavaScript、CSS 和图像)也在 public 目录的子目录中。
我希望人们能够通过/properties 访问该应用程序。此外,还会有对其他页面的请求(如/properties/admin)以及对静态资产的请求(如/properties/assets/css/style.css)。
我已经完成了 90% 的工作。 DocumentRoot 中的 .htaccess 文件如下所示:
RewriteEngine On
RewriteRule ^properties/?(.*)$ /listings/public/index.php/$1 [L]
在public 目录中,还有另一个.htaccess 文件,如下所示:
Options +FollowSymLinks -Indexes
RewriteEngine on
# Send request via index.php (not if its a real file or folder)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
我将 FuelPHP 配置中的 $base_url 设置为 http://example.com/properties/。静态资产的所有 URL 都以我期望的方式显示,例如,我的 bootstrap.css 文件的路径显示为 http://example.com/properties/assets/css/bootstrap.css。这是我所期望的。然而,Apache 没有抓取静态资源,而是通过 FuelPHP index.php 文件运行请求,导致 404。
我想我需要在DocumentRoot 中的.htaccess 文件中添加一个RewriteCond,但我不确定这是否正确,或者RewriteCond 会是什么样子。
如何调整我的 .htaccess 文件,以便能够访问静态资产,例如实际位于 <DocumentRoot>/listings/public/assets/css/bootstrap.css 的 http://indyapm.com/properties/assets/css/bootstrap.css?
【问题讨论】: