CodeIgniter 4 Css和Js 404和403

busg9geu  于 2023-06-19  发布在  其他
关注(0)|答案(1)|浏览(79)

我有一个正在运行的CI 4应用程序,在一些不幸的事件后,我重新安装了整个系统在我的服务器上。
我在Centos 7上使用Plesk,现在我使用Ubuntu 22.04。我创建了一个子域,然后上传了我的CI 4代码。我修改了我的http.conf并将public附加到文档根目录。
接下来,我检查了我的app/Config/App.php
public $baseURL = 'https://patron.berkyazilim.com/';
我的主页已加载,但没有找到CSS文件。
我查过了,我在用
<link rel="stylesheet" href="<?= base_url('css/style.default.css') ?>">
文件可用。但是文件返回404。
这里是我的public/css

custom.css              style.default.css          style.green.min.css      style.pink.min.css.map  style.sea.css          style.violet.min.css
style.blue.css          style.default.min.css      style.green.min.css.map  style.red.css           style.sea.min.css      style.violet.min.css.map
style.blue.min.css      style.default.min.css.map  style.pink.css           style.red.min.css       style.sea.min.css.map
style.blue.min.css.map  style.green.css            style.pink.min.css       style.red.min.css.map   style.violet.css

我可以加载custom.css,但style.default.css无法加载。
参见:
https://patron.berkyazilim.com/css/custom.css <-装载
https://patron.berkyazilim.com/css/style.default.css <-未加载
这里我的.htaccess

# Disable directory browsing
Options All -Indexes

# ----------------------------------------------------------------------
# Rewrite engine
# ----------------------------------------------------------------------

# Turning on the rewrite engine is necessary for the following rules and features.
# FollowSymLinks must be enabled for this to work.
<IfModule mod_rewrite.c>
        Options +FollowSymlinks
        RewriteEngine On

        # If you installed CodeIgniter in a subfolder, you will need to
        # change the following line to match the subfolder you need.
        # http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
        # RewriteBase /

        # Redirect Trailing Slashes...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_URI} (.+)/$
        #RewriteCond $1 !^(index\.php|assets|assets/css|assets/js|assets/etc|robots\.txt)
        RewriteRule ^ %1 [L,R=301]
        #RewriteRule ^(.*)$ /gestion/index.php/$1 [L]

        # Rewrite "www.example.com -> example.com"
        RewriteCond %{HTTPS} !=on
        RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
        RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

        # Checks to see if the user is attempting to access a valid file,
        # such as an image or css document, if this isn't true it sends the
        # request to the front controller, index.php
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]

        # Ensure Authorization header is passed along
        RewriteCond %{HTTP:Authorization} .
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

<IfModule !mod_rewrite.c>
        # If we don't have mod_rewrite installed, all 404's
        # can be sent to index.php, and everything works as normal.
        ErrorDocument 404 index.php
</IfModule>

# Disable server signature start
        ServerSignature Off
# Disable server signature end
sqyvllje

sqyvllje1#

事实证明,不应该编辑Plesk生成的HTTP配置(NginxApache)文件。原因有二:
1.他们不会工作。
1.在每次重新启动HTTP服务后,都会重新生成这些文件。
相反,只需打开面板,转到Domains-> Hosting & DNS -> Hosting并在那里更新Document根目录。
这样做解决了问题。。

相关问题