I'm having a problem with CakePHP, the CSS is not found. When I view the source code in my browser I can see the cake generic CSS link in the head section. But when I click on it to see the actual source code, I get a 404 not found error.
i follow this actions:
uncommented
Configure::write('App.baseUrl', env('SCRIPT_NAME'));
in app/config/core.php , because rewrite module is disable.
delete .htaccess file from / and /app and /app/webroot.
run project.
php code in default is :
app/View/Layouts/default.ctp
echo $this->Html->css('cake.generic');
and its html code is:
<link rel="stylesheet" type="text/css" href="/app/webroot/css/cake.generic.css" />
this file exist really, but when i click to /app/webroot/css/cake.generic.css in source of browser code i face
404 Not Found
Is way?
I'm assuming your virtual hosts document root points to app/webroot so your links to the css files need to point to /css/file.css. The way you have it now it's actually looking for app/webroot/app/webroot/css and that's why you get a 404.
Either that or your .htaccess is wrong or you stylesheet doesn't actually exist. Let me know if this helps and i can update my answer if needed.
Already,i face this problem. i change permission for app and webroot and css folders. i offer this for you too.
Related
I came across problem in laravel, cant find a solution, maybe you could help me out.
I have many folders with HTML documents that are linked (same folder as HTML) with css, some of css are inside assets, includes, root folder.
I can access these html files by going https://website.com/live/1/index.html but the problem is that laravel sees css and other files in website root folder https://website.com/assets/app.css instead of https://website.com/live/1/assets/app.css
I think I could find a solution in htaccess by typing RedirectMatch 301 ^/(assets/.+)$ /live/1/$1 but then it means, that I have to create and edit htaccess everytime for a new folder.
Maybe someone has any solution to this problem ?
You can change your default asset URL with your .env file and add this
ASSET_URL=https://website.com/live/1
it would change your asset() method behavior
So I'm very new to Laravel and I'm following a tutorial to use the authentication feature. This works fine, however it is unable to find my scripts and stylesheets. I haven't made any new ones nor have I touched the stylesheet link in app.blade.php, so I have no clue why it is throwing this error.
Code:
<link href="{{ URL::asset('css/app.css') }}" rel="stylesheet">
Error:
GET http://localhost:8000/css/app.css net::ERR_ABORTED 404 (Not Found)
When I go to locahost/css/app.css I get a 404 error. The same error is occurring with app.js. I haven't changed anything about the file structure and it was all generated with composer create-project laravel/laravel
Thanks.
Laravel doesn't include any CSS files by default. You need to create one yourself and put it to /public/ directory, so in your case that would be /public/css/app.css.
Does localhost point to public in your project? Usually you would have to open http://localhost/public
Per default, URL::asset('css/app.css') expects a css file at /public/css/app.css -- for your setup (serving throught php artisan serve, I suppose?), that would be http://localhost:8000/public/css/app.css.
Anyway: If there is no stylesheet, just create one. There is tons of ways how to do it, depending on your needs. Creating one manually for one, but for complex sites think about using laravel mix for compilation. Or anything other way!
Make sure your style exists at public/css directory, then try this code:
<link rel="stylesheet" href="{{asset('css/app.css')}} type="text/css"/>
if the file doesn't exist, create that and try again.
I hope this can help you.
I have the following public structure in my application:
public
css
images
javascript
fonts
I also have this in my htaccess file:
RewriteEngine on
RewriteBase /
RewriteRule !\.(js|ico|txt|gif|jpg|png|css|ttf|svg|eot|woff)$ index.php
In the application CSS, JS and Image files work as expected and will not go through the autoloader. I assume this is due to the rewrite rule above.
BUT
I have just downloaded a SocialIcon pack and i've saved this to /fonts. In my CSS i use this to load the font files in:
src: url('/fonts/socicon-1.3/socicon.eot');
(note: followed an example by the developer to get this working in my CSS)
The file exists, has the same permissions as everything else and the eot file has been ignored with the rewrite rule.
But when i try to use the new fonts i get a 403 error. Apparently example.com/fonts/socicon-1.3/socicon.eot doesnt exist when it does. I'm thinking i might have some issues with Zend doing something with Fonts?
Can anyone suggest how i fix this permission error?
Holy Smokes!
I'm a little silly. Seems the issue was actually a 403. I had the wrong permissions on the Folder. So i chmod 775 and it works.
Unless 775 isnt the best one?
I am uploading a bootstrap template through Heroku. The name of the template is: Brushed. http://www.alessioatzeni.com/blog/brushed-template/
I route to the home page through a php file with the following code:
<?php include_once("home.html"); ?>
Everything works in the emulator on cloud9, however, when I upload it to Heroku only my HTML shows up without any of my CSS. Does anyone have any idea of what I can do?
Here is a link to my site: https://mariatorres.herokuapp.com/
It is not a rails app, just a static bootstrap template.
If you use Chrome's Code Inspector and go to Network, and try to reload your webpage, you will see that the .css files are 404 not found... you can reproduce the same if you load your webpage, open it's source and see (and try to open) the .css links.. you will see that they are not found. To fix this, where you load the .css files try to use the full path of the CSS, or if you rewrite/route your paths, fix the path to the CSS files..
Only by showing us the include statement, is not enough..
I have a problem which I find fairly strange, maybe someone can help me.
I use cakephp. My web root folder for apache is /home/jw/www. My project is under /home/jw/www/hc2, so the overall folder structure (only the parts important for this question) is:
www
/hc2
/app
/webroot
index.php
/css
/cake.generic.css
/any.css
/other.css
/stylesheets.css
/js
/any.js
/javascript.js
/files.js
Well, cakephp works fine so far - routing (with mod_rewrite enabled), database connection etc. works.
The one but huge problem is: No .css- or .js-files are loaded, except the cake.generic.css!
The part of the .cpt-template, where I load css and js files looks something like:
echo $this->Html->css('cake.generic');
echo $this->Html->css('bootstrap.min');
echo $this->Html->css('layout');
echo $this->Html->script('bootstrap.min');
echo $this->Html->script('jquery-2.0.3.min');
In the html- of the loaded page this becomes e.g.:
<link href="/hc2/css/cake.generic.css" type="text/css" rel="stylesheet">
<link href="/hc2/css/bootstrap.min.css" type="text/css" rel="stylesheet">
But when I examine those two with firebug, I see that the first of those is loaded correctly - I can see the css-definitions of the file - while the other one receives an error 403!
Is it maybe a mod_rewrite-problem? But since I can access all controllers just the way it should be, I can't quite imagine that... Does anyone maybe have an idea? Would be very happy, thanks...
Sry, I solved it myself - thanks to the help of #mvanderw.
It had nothing to do with cakephp/apache/mod_rewrite whatsoever. The problems were the File permissions. For some reason, I had copied all files except the cake.generic.css (which I downloaded) from my windows file system (on the same device) an for some reason, they were coming with the permissions 600.
chmodded to 644 now and everything works. So maybe this helps someone sometime in the future with a similar problem... :)