1

我有一个 FuelPHP 应用程序,我正在尝试设置它来扩展现有网站(我们称之为example.com)。FuelPHP 安装在一个listings名为DocumentRoot. 但是,应用程序的主index.php文件位于listingscalled的子目录中public,因此文件的实际路径index.php<DocumentRoot>/listings/public/index.php. 应用程序的静态资产(JavaScript、CSS 和图像)也位于目录的子目录中public

我希望人们能够在/properties. 此外,还会有对其他页面的请求(例如/properties/admin)以及对静态资产的请求(例如/properties/assets/css/style.css)。

我已经得到了大约 90% 的工作。中的.htaccess文件DocumentRoot如下所示:

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]

我将$base_urlFuelPHP 配置中的http://example.com/properties/. 静态资产的所有 URL 都以我期望的方式显示,例如,我的bootstrap.css文件的路径显示为http://example.com/properties/assets/css/bootstrap.css. 这是我所期望的。然而,Apache 并没有抓取静态资源,而是通过 FuelPHPindex.php文件运行请求,导致 404。

我想我需要在RewriteCond中的.htaccess文件中添加一个DocumentRoot,但我不确定这是否正确,或者RewriteCond会是什么样子。

如何调整我的.htaccess文件,以便我能够访问静态资产,例如http://indyapm.com/properties/assets/css/bootstrap.css实际位于的文件<DocumentRoot>/listings/public/assets/css/bootstrap.css

4

1 回答 1

1

我相信你想要的是一个 RewriteBase

RewriteEngine On # after this
RewriteBase /properties/ # insert this

也就是说,使用正确的基本 url 设置主配置应该可以解决问题。

于 2013-09-13T16:01:36.440 回答