Heroku PHP index.html loads but not style.css or javascript - php

I have a simple site where users can write messages & it saves them to the server, or they can read any other message people have wrote on the server too. I wrote the server side in PHP and everything works great on my localhost. I only have 2 PHP files and they get called either on a form submit or via an ajax request. I deployed my site to Heroku, but the only thing that works/displays right now is my index.html. Inside index.html I do not even deal with Javascript or the PHP files, it's simply that the CSS isn't showing. I have Procfile and composer.json at the root of the project, and everything else in /website/.
My composer.json is empty(it's just { } )
My Procfile is
web: vendor/bin/heroku-php-apache2 /website
And my index.html head css reference looks like this:
<link rel="stylesheet" type = "text/css" href="/website/style.css">
Any ideas on how to fix this issue? Thank you!

Related

Heroku deployment error of static website

I deployed a static html, css, JS application to heroku using a dummy php file to trick heroku. I also added a composer.json file to the root directory. I successfully deployed the website but when it's opened all the css and JS properties are lost.
Any ideas?
here is the content of my php file:
<?php
include("index.html");
?>
Using this code will work it out.
Create a file named index.php on Github and paste this code.
<?php header ( 'Location:/index.html '); ?>
*When you want to deploy a static web page to Heroku, it asks you to build it with php. (Although this is just html and css files.)

Uploading HTML Files to Display on Openshift PHP 5.4 Website?

I can't get these html files to display AS my Openshift site. Only the default Openshift created index.php file shows up (which I have edited; see "Test Test Test" as h1). How do I get MY html files to appear as the HOME page, etc. when I click on my http:/php-....rhcloud.com/ domain name?
It seems that you would like to replace the default index.php, which comes with the PHP 5.4 cartridge, with your own static Index.html page. To do that, simply:
delete the index.php from the repo
rename the Index.html to index.html (so it now starts with a lowercase i)
git add, git commit and git push both changes
...and your index.html will be rendered by the server instead as the index page when you visit your domain.

CSS won't work through Heroku when routed through PHP

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..

Laravel 4 treating files as routes in laravel 4

I am just trying to host a laravel site to production. There is an error with the routing all my css and javascript files are being treated like a route instead of files and they are not loading
<script src='http://project.com/project/assets/js/jquery-1.9.1.js' type='application/javascript'></script>
I can see that this html is generated but the files are not being loaded When I click on the link I get a NotFoundHttpException
This is wroking fine in my local machine. This error is present only in live server.
Thanks in advance!
The src link to your js file is set using Laravel's HTML::script()? If not change it because this will help so that you can have proper full urls for js and css files. So if you have a js file like public/assets/js/custom.js you should call it like this:
{{ HTML::script('assets/js/customs.js') }}
and you will be fine. Just remember that your starting point for assets is inside public folder. HTML::script() or HTML::style() get you there at once.
It turns out the issue is with nginx configuration. The root folder to the server was set incorrectly. So it was looking for differnt files. Not a code issue just and issue with the server environment

Cakephp only loads one .css-file - 403-Error for all others

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... :)

Categories