公共和燃料文件夹位于同一子目录中,但 URL 中没有公共/



在一遍又一遍地阅读了 Fuel PHP 的安装说明(我喜欢)之后,我不知道如何在没有显示 public/的 url 和不从 docroot 移动燃料文件夹的情况下使应用程序工作。(所以它都是包含的)。

我的设置是这样的:

/Users/AeroCross/Sites(这是 MAMP 加载所有文件的地方,即本地主机) /Users/AeroCross/Sites/projects/mariocuba(这是燃料应用程序的网页根目录)

其中包含:

    mariocuba/
        .htaccess
        oil
        fuel/
            app/
            core/
            packages/
        public/
            .htaccess

mariocuba文件夹中的.htaccess

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /public
RewriteRule ^(/)?$ index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

public文件夹中的 .htaccess :

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

如果我尝试加载应用程序(/用户/AeroCross/站点/项目/mariocuba/),则会出现此错误:

Not found.
The requested URL /public/index.php/ was not found on this server.

我不知道在这里做什么。

我知道这不是为了以这种方式工作而设计的,我知道这是不安全的,但这是为了开发和版本控制目的。我能做些什么(对文件系统进行最少的调整)来完成这项工作?

值得注意的是,我的config.php文件配置了base_url = nullindex_file = null

任何帮助表示赞赏!

从/mariocuba 中删除现有的 .htaccess 文件,将/mariocuba/public(包括 .htaccess)的内容移动到/mariocuba 中,然后编辑 index.php。

改变:

/**
 * Path to the application directory.
 */
define('APPPATH', realpath(__DIR__.'/../fuel/app/').DIRECTORY_SEPARATOR);
/**
 * Path to the default packages directory.
 */
define('PKGPATH', realpath(__DIR__.'/../fuel/packages/').DIRECTORY_SEPARATOR);
/**
 * The path to the framework core.
 */
define('COREPATH', realpath(__DIR__.'/../fuel/core/').DIRECTORY_SEPARATOR);

自:

/**
 * Path to the application directory.
 */
define('APPPATH', realpath(__DIR__.'/fuel/app/').DIRECTORY_SEPARATOR);
/**
 * Path to the default packages directory.
 */
define('PKGPATH', realpath(__DIR__.'/fuel/packages/').DIRECTORY_SEPARATOR);
/**
 * The path to the framework core.
 */
define('COREPATH', realpath(__DIR__.'/fuel/core/').DIRECTORY_SEPARATOR);

此处的安装说明中对此进行了详细说明:http://docs.fuelphp.com/installation/instructions.html#/manual

在根目录中添加一个 .htaccess 文件,并使用以下重写规则:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /YOUR_LOCAL_PROJECT_FOLDER/public
    RewriteRule ^(/)?$ index.php/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

注意:将 .htaccess 上传到主机后,您需要对其进行编辑(因为它无法动态计算。

如果您想隐藏公共文件夹下的所有内容(我经常这样做),请使用它作为根目录中的那个:

RewriteEngine on
RewriteRule ^(.*) public/$1 [L]

这可确保所有资源也重定向到公共资源。因此,每一件非公开的事情都是绝对安全的。

最新更新