gpt4 book ai didi

php - 在 AWS 的子文件夹中设置 cakephp

转载 作者:搜寻专家 更新时间:2023-10-31 21:58:09 25 4
gpt4 key购买 nike

我已将我的 cakephp 网站转移到 AWS ubuntu 机器上的一个子文件夹中。站点正常运行,但 CSS、图像和 JS 未加载。我收到 404 未找到错误。

Not Found

The requested URL /demo/css/mscrollar/jquery.mCustomScrollbar.min.css was not found on this server.

Urls 仅适用于 index.php。

这是htaccess

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /demo
RewriteRule ^media/(.*) http://%{HTTP_HOST}/files/timthumb.php?src=http://%{HTTP_HOST}/app/webroot/files/$1 [L,R=301]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

请帮忙

最佳答案

您需要创建两个 htaccess 文件。一个在 webroot 中,一个在根路径中。根 (./.htaccess) 中的那个应该如下所示(替换 YOUR_PATH):

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /YOUR_PATH
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

webroot 文件夹 (./app/webroot/.htaccess) 中的那个应该如下所示:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

关于php - 在 AWS 的子文件夹中设置 cakephp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31290235/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com