Image URL in CSS is not working in Laravel 7 - css

I am using Laravel 7.
Location of app.scss : resources/saas/app.scss
Location of app.css : public/css/app.css
In app.scss
background-image: url("../public/images/homeheaderBg.jpg");
on Welcome.blade.php image is not displaying due to wrong Image URL
Wrong Image URL is :
http:localhost/images/homeheaderBg.jpg?325adac1518a8631dcc08fdb07bef837
It should
http:localhost/website_name/images/homeheaderBg.jpg

use
php artisan serve
in your terminal in this way your website link will be
http://localhost:8000
and in this way the right URL will become
localhost/images/homeheaderBg.jpg

Related

cakephp 3.6 can't Display Image

I have problem when I Try Display Image on my login page It doesn't appear
<?= $this->Html->image('crm.jpg', ['alt' => 'User image']); ?>
When I check the console on Chrome
Failed to load resource: the server responded with a status of 404 (Not Found)
When I try accessing http://localhost/intellix/img/crm.jpg it says
Error: ImgController could not be found.
Which isn't needed.
crm.jpg is located in webroot/img/
Now the weird part if i change crm with another image name ex: silhouette.png it works fine but so far it only worked with this one
Any Ideas ?
(Note : Using Chrome Cakephp Sublime text Up to date)
Edit : I had the same problem trying to load CSS Scripts Files
It seems that your image crm.jpg does not exist. In this case, CakePHP is routing the request to ImgController. Is the image silhouette.png located in the same directory?
A second thing might be the access right. Maybe it is not readable? Check the access rights and make it at least readable for all.
the problem was indeed in access right in this file
.htaccess inside webroot folder
There was this line which I added
RewriteRule ^(.*)$ index.php [QSA,L]
Restoring it to default Removing it did the trick

Webpage is referencing the wrong path. What do I need to do to get it to reference the correct path

I have a gif file in a folder called imgs. When I load my HTML file I get the following error:
http://localhost:63342/AllFours/css/imgs/cardback.gif Failed to load resource: the server responded with a status of 404 (Not Found).
This is the reference in my CSS file: background-image: url("imgs/cardback.gif");
This is an image of my folder:
Assuming your CSS file is on ~/AllFours/css/ and your imgs folder is on ~/AllFours/imgs/ use this to get an image:
url("../imgs/cardback.gif")

Symfony2: Stylesheets loaded but not applied on NGINX leading to broken error pages

I've just installed a fresh and clean Symfony app. I'm using NGINX as my webserver.
The stylesheets don't show a http 404 error code in devtools network-tab and i can see their content in the preview-tab correctly.
example picture:
Did someone face any issue like this? I'm guessing it might be a permission issue...
EDIT #1: Attached a picture of the chrome devtools showing the css are loaded correctly.
You need to make sure your nginx.conf actually includes the correct mime-types.
http {
include conf/mime.types;
# ...
... or ...
types {
# ...
text/css css;

Problems with image path

I have a project built in CodeIgniter. In my localhost, the website work fine, but in the remote server, fail the image inclusion from CSS & JS.
The site, is guest in a subdomain. The server file system hierarchy is:
--/
---apps (subdomain folder for my app)
----application
----[other CI forlders]
----css
----js
----img
--[other web folders (no CI)]
--index.html
In CSS files i define the images paths this way: "../img/"
For example:
#maincontainer {background-image: url('../img/main_bg.gif');}
But, in Chrome and FF, show error to load resources:
Failed to load resource: the server responded with a status of 404
(Not Found) http://apps.manantiales.edu.ar/img/main_bg.gif
Any ideas?
You are on a subdomain, therefore, the correct path would be:
http://manantiales.edu.ar/apps/img/main_bg.gif
You can use rules in your htaccess file to make the subdomain path work
or
Just use absolute paths like diEcho suggested. You can embed php code in css files like this:
maincontainer {background-image: url('< ?php echo site_url('img/main_bg.gif');?>');}
(I have put an extraspace at < ?php as not sure how to format it to show correctly here)
You can simply do it like this
--/
---apps (subdomain folder for my app)
----application
----[other CI forlders]
--[other web folders (no CI)]
--index.html
--css
--js
--img
#maincontainer {background-image: url('../img/main_bg.gif');}
and in html files;
<?= base_url();?>css/css.css

How to configure nginx to serve versioned css and javascript files

My css files named main.css?v=1.0.0 , site.css?=v.1.0 .
how to configure nginx to serve this kind of files(not extension with .css or .js but with a version number)
FYI:
all the files are in the right path and erro message in chrome dev tool console is file not found(404)
Thanks !
When you're trying to access main.css?v=1.0.0 or main.css?v=2.0.0 any webserver will point it to the same file, main.css
.
Well in your situation coud create a separate location for your versioned file, and then use the next code in the nginx config:
location = /main.css {
if ($arg_v) {
rewrite ([0-9]+) /where/maincss/versions/stored/main-$avg_v.css last;
}
// otherwise default main.css
}
The same thing'll be for the any other file

Resources