【发布时间】:2021-12-07 23:08:50
【问题描述】:
我昨天已将我的网站推送到生产环境,我创建的 3 个 .htaccess 文件一切正常。唯一的问题是我的 webroot 文件夹中的图像没有显示。 我用 $this->Url->image('pages/' . $page->image)
给他们打电话在 html 中呈现的链接:
背景图片:url(/app/img/pages/home.jpg);
'App' => [
'namespace' => 'App',
'encoding' => env('APP_ENCODING', 'UTF-8'),
'defaultLocale' => env('APP_DEFAULT_LOCALE', 'fr_FR'),
'defaultTimezone' => env('APP_DEFAULT_TIMEZONE', 'Europe/Brussels'),
'base' => false,
'dir' => 'src',
'webroot' => 'webroot',
'wwwRoot' => WWW_ROOT,
//'baseUrl' => env('SCRIPT_NAME'),
'fullBaseUrl' => false,
'imageBaseUrl' => 'img/',
'cssBaseUrl' => 'css/',
'jsBaseUrl' => 'js/',
'paths' => [
'plugins' => [ROOT . DS . 'plugins' . DS],
'templates' => [ROOT . DS . 'templates' . DS],
'locales' => [RESOURCES . 'locales' . DS],
],
],
/var/htdocs/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
/app/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/app/webroot/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
谢谢。
【问题讨论】:
-
如果添加 'fullbase' => true 会怎样?例如$this->Url->image('pages/' . $page->image, ['fullBase' => true])
-
我已经试过了,没有任何改变。
-
也许尝试将 RewriteBase / 移动到 /app/.htaccess 而不是 /app/webroot/.htaccess?
-
也不工作...:/
-
你能直接访问那个文件吗?试试
background-image:url("/img/pages/home.jpg");
标签: .htaccess cakephp cakephp-4.x