My Laravel project run correctly on my localhost but when I upload on 000webhost it just show me html data and css,js,images file don't. This is a example about css files, I use this to link css files:
<link href="{{asset('public/frontend/css/bootstrap.min.css')}}" type="text/css" rel="stylesheet">
Here is my file structure
-app
-bootstrap
-config
-database
-public
--frontend
---css
----bootstrap.min.css
----some files css in here
---fonts
---images
---js
-public_html
-resources
--views
---index.blade.php
-routes
-storage
...
When I run it take 2 errors:
Refused to apply style from
'https://...000webhostapp.com/public/frontend/css/bootstrap.min.css'
because its MIME type ('text/html') is not a supported stylesheet MIME
type, and strict MIME checking is enabled.
And
Failed to load resource: the server responded with a status of 404 ()
All css,js,image files have 2 errors.
Solved!! I really don't understand but i just move public folder into public_html folder and it worked
Related
I have a problem with my application not finding my static files. This however only happens on a certain level. As you can see from the code fragments below, the css, images, js, etc works on certain files and not on others. Not sure what I am missing here.
My Stack: Spring Boot, Thymeleaf
Part of my application.yml file:
server:
port: 8090
servlet:
context-path: /myapp
My application public resources directory structure:
/resources
/public
/css
/images
/js
My application template structure and where the styles and images work:
/resources
/templates/index.html (works)
/templates/admin/index.html (works)
/templates/admin/user/admin/showuser.html (does not work)
Code from /resources/admin/fragments/header.html (Used as a header file for other files)
<!DOCTYPE html>
<html>
<head>
<link href="css/mycss.css" rel="stylesheet">
Code from /resources/templates/index.html (works) (Does not include the header.html fragment)
<link href="css/mycss.css" rel="stylesheet">
Code from /resources/templates/admin/index.html (works) (Includes header.html as a fragment using Thymeleaf)
<!--/*/ <th:block th:include="/admin/fragments/header"></th:block> /*/-->
Code from /resources/templates/admin/user/admin/showuser.html (does not work) (Includes header.html as a fragment using Thymeleaf)
<!--/*/ <th:block th:include="/admin/fragments/header"></th:block> /*/-->
Not sure how to fix this.
Thank you!
When your urls don't begin with a slash /, they attempt to resolve the current directory. For example:
Page: /templates/index.html
Css: css/mycss.css
The browser tries to locate /templates/css/mycss.css
If the cases that don't work:
Page: /templates/admin/user/admin/showuser.html
Css: css/mycss.css
The browser tries to locate /templates/admin/user/admin/css/mycss.css
If you want to make sure your css works everywhere, you need to make sure the link points consistently to the correct location. I'm guessing something like this would work:
<link th:href="#{/css/mycss.css}" rel="stylesheet">
(Using Thymeleaf to add the context, and to make the path absolute.)
My group mates have an existing project it runs very fine in their computer but when i try to run it in my laptop, it will not read its linked CSS. what seems to be the problem?
the error in the cmd is this.
If you use absolute path replace with:
<link rel="stylesheet" href="{{ URL::asset('css\main.css') }}">
in your master blade layout.
Replace main.css with the name of your css file.
OR
Check security settings (Right click/Properties/Security)
When I run my index.html file in my (typescript) Angular 2 app which is also a Parse.com app (It has the cloud and public, parse.local and parse.project directories etc) it runs fine. But when I try to deploy it to Parse.com it doesn't deploy.
A lot of errors show in the terminal saying Bad file name for the files in the node_modules folder.
Is my node modules folder in the wrong directory? Or do I need to get rid of all of the files that have a bad file name according to parse.com?
Here is my project file structure:
Here is a sample of the error log in the terminal after typing parse deploy from the root directory of my project - The actual error log is too big to paste the whole thing. Notice that it says
Open file xxx - too many open files
open
/Users/Ben/development/whatwegrowangular2/public/node_modules/zone.js/lib/patch/define-property.js:
too many open files | open
/Users/Ben/development/whatwegrowangular2/public/node_modules/zone.js/lib/patch/event-target.js:
too many open files | open
/Users/Ben/development/whatwegrowangular2/public/node_modules/zone.js/lib/patch/file-reader.js:
too many open files | open
/Users/Ben/development/whatwegrowangular2/public/node_modules/zone.js/lib/patch/functions.js:
too many open files | open
/Users/Ben/development/whatwegrowangular2/public/node_modules/zone.js/lib/patch/geolocation.js:
too many open files | open
/Users/Ben/development/whatwegrowangular2/public/node_modules/zone.js/lib/patch/mutation-observer.js:
too many open files | open
/Users/Ben/development/whatwegrowangular2/public/node_modules/zone.js/lib/patch/promise.js:
too many open files | open
/Users/Ben/development/whatwegrowangular2/public/node_modules/zone.js/lib/patch/property-descriptor.js:
too many open files | open
/Users/Ben/development/whatwegrowangular2/public/node_modules/zone.js/lib/patch/register-element.js:
too many open files | open
/Users/Ben/development/whatwegrowangular2/public/node_modules/zone.js/lib/patch/websocket.js:
too many open files | open
/Users/Ben/development/whatwegrowangular2/public/node_modules/zone.js/lib/utils.js:
too many open files | open
/Users/Ben/development/whatwegrowangular2/public/node_modules/zone.js/lib/zone.js:
too many open files | open
/Users/Ben/development/whatwegrowangular2/public/node_modules/zone.js/lib/zones/long-stack-trace.js:
too many open files | open
/Users/Ben/development/whatwegrowangular2/public/node_modules/zone.js/package.json:
too many open files | open
/Users/Ben/development/whatwegrowangular2/public/package.json: too
many open files | open
/Users/Ben/development/whatwegrowangular2/public/tsconfig.json: too
many open files
Here is another sample of a different error from the same terminal:
Bad file name:
node_modules/fsevents/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json
| Bad file name:
node_modules/fsevents/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js
| Bad file name:
node_modules/fsevents/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown
| Bad file name:
node_modules/fsevents/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js
| Bad file name:
node_modules/fsevents/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json
| Bad file name:
node_modules/fsevents/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js
| Bad file name:
node_modules/ua-parser-js/test/browser&mediaplayer-test.json Will
retry in 1 seconds
EDIT: I moved the node modules that were actually used out of the node_modules folder and deleted the node_modules folder. The index.html file still runs and looks fine. But when I try to deploy to parse.com, I get this error now:
Finished uploading files Deploy failed with error: You have 3029
hosted files but are limited to 500 Will retry in 0 seconds.
I have to load all node_modules via a CDN script tag in my html file, not by having the actual node_module files in my project.
At this stage I have these two script tags and it kinda works (All that is on the page is an angular 2 component which has a bootstrap danger button - It works fine it just loads kinda slow):
<script src="https://code.angularjs.org/2.0.0-alpha.47/angular2.dev.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.18.4/system-csp-production.js"></script>
I get these errors in the console:
Uncaught ReferenceError: System is not defined bootstrap.min.js:6
Uncaught Error: Bootstrap's JavaScript requires jQuery bundle.js:27364
Angular 2 is running in the development mode. Call enableProdMode() to
enable the production mode. angular2.dev.js:138
http://whatwegrowangular2.parseapp.com/app/bundle.js did not call
System.register or AMD define Error loading
http://whatwegrowangular2.parseapp.com/app/bundle.js
Please comment with any other cdn script tags to include in my index.html file to get rid of all errors. Thanks.
Here is my full index.html file:
<html>
<head>
<title>Angular 2 QuickStart</title>
<!-- 1. Load libraries -->
<script src="https://code.angularjs.org/2.0.0-alpha.47/angular2.dev.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.18.4/system-csp-production.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<!-- 2. Configure SystemJS -->
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/bundle')
.then(null, console.error.bind(console));
</script>
</head>
<!-- 3. Display the application -->
<body>
<my-app>Loading...</my-app>
</body>
</html>
Is it possible with a .htaccess redirect to have all style sheets and image paths, that are located in a subfolder, point to the appropriate folder(images/styles) in the the root folder? With out having to change the path in each file.
Let me try to explain my situation a little better.
Im using an include (header.inc.php) that contains my doctype, stylesheet links
<link href="styles/layout.css" rel="stylesheet" type="text/css">
and a couple other html element/images.
That becomes an issue when header.inc.php in pulled into my subfolder files, because style/layout.css does not exist in that folder. Additionally there are
a couple images that break because of the same reason,
<img src="images/image.jpg">
the images folder does not exist…
In my current .htaccess file, I have the below script with my include path (for local testing). Is there something similar to the include_path script that can help with the issues listed above?
php_value include_path ".:/Applications/MAMP/bin/php/php5.4.4/lib/php:/Applications/MAMP/htdocs/site/inc"
Here is an example of the file structure/hierarchy.
[ROOT FOLDER]
index.php
/subfolder
subpage1.php
subpage2.php
subpage3.php
/subfolder2
subpage1.php
subpage2.php
subpage3.php
contact.php
/images
/styles
/scripts
/inc
You don't need to use rewrites to solve this you just need to now how to define the source properly in your HTML elements.
Don't do this
<link href="styles/layout.css" rel="stylesheet" type="text/css">
Do this
<link href="/styles/layout.css" rel="stylesheet" type="text/css">
What this has changed is that your path is no longer relative to the file being browsed to but is now relative to the root of your web site.
Hope that helps.
I have
<link href="/smarter-computing/us/en/sc-mobile.css" type="text/css"/>
<script src="/smarter-computing/js/sc-common.js?fileversion-r21" type="text/javascript">//</script>
When I am working on these files locally I have to keep append //localhost/~vc/ before the path for JS and CSS files. I don't want to keep copy/pasting this path for the following and every <img> links in my code.
How can I use htaccess to redirect all url's pointing to //localhost/smarter-computing/ or /smarter-computing/ to append this path //localhost/~vc/ before my /smarter-computing path.
Thank you,
Vishwas
You can either make the document root your home directory in your apache config in localhost, or add this to the header of your pages:
<base href="/~vc/">