Php 在共享托管公共资产中部署codeigniter 4将导致404
我有一个codeigniter 4项目的新设置,它在本地运行良好,我能够加载资产。 当我上传到网上时,资产无法加载,导致404,但我可以加载视图 这是我的htaccess,默认情况下与Php 在共享托管公共资产中部署codeigniter 4将导致404,php,codeigniter,codeigniter-4,Php,Codeigniter,Codeigniter 4,我有一个codeigniter 4项目的新设置,它在本地运行良好,我能够加载资产。 当我上传到网上时,资产无法加载,导致404,但我可以加载视图 这是我的htaccess,默认情况下与public中的CodeIgniter文件一起使用: # Disable directory browsing Options All -Indexes # ---------------------------------------------------------------------- # Rewri
public
中的CodeIgniter文件一起使用:
# 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
RewriteRule ^(.*)/$ /$1 [L,R=301]
# 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
现在我有两个htaccess,一个在root
中,即public\uhtml
中,另一个在public
但是仍然无法加载资产。您的“共享主机”是否使用public\u html作为文档根?是的,它使用public\u html作为根当您查看页面源或检查元素时,您的资产指向什么url?请参阅您的“共享主机”是否使用public\u html作为文档根?是,它使用它作为根当您查看页面源或检查元素时,您的资产指向哪个url?请参阅
DirectoryIndex /public/index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|assets|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./public/index.php/$1 [L,QSA]