Exclude direct paths on server, i.e. css, js, etc - php

I am experimenting with Laravel 4, I have successfully installed and did a couple things and that. Unfortunately, I cannot load any CSS into my HTML.
The CSS url is correct, which I used HTML::style('css/bootstrap.css'); to generate for me.
When I access the URL (currently on localhost) http://laravel.dev/css/bootstrap.css, it gives me an error:
Not Found
The requested resource /css/bootstrap.css was not found on this server.
The file is stored in /public/css/bootstrap.css, why can't Laravel avoid this? How would I overcome this issue? It seems that the route is going forward with the application rather than finding the file on the server.
I am running Laravel on my localhost environment, PHP 5.4.0, Mac OS X 10.7.

You probably have a problem with your virtual host or .haccess file, because
HTML::style('css/bootstrap.css');
Should point to
http://laravel.dev/css/bootstrap.css
And it is doing it correctly, but your virtual host configuration for http://laravel.dev/ should point to
/var/www/laravel.dev/public/
So, that file, in fact, is
/var/www/laravel.dev/public/css/bootstrap.css
If you get a file not found on
/css/bootstrap.css
Then I have to assume this is a virtual host or rewrite (.htaccess) configuration problem.

You have to put the assets folders in your root outside public directory according to HTML::style.
Otherwise you can access by http://laravel.dev/public/css/bootstrap.css

Related

images and css not loading on local wamp server using PHP

I have ran into a problem where by using /js/filename.js or /images/image.jpg etc is not loading anything on my WAMP Server. What it seems like is that its not getting the base url properly here. Screenshots will give you better idea.
Trying to reference the files with "/" in the start but it fails to load anything. I need to have it because i would be working with URL Rewrites so in that case it should load the files from there. Please let me know about any wamp server setting that is causing this issue.
Regards.
You are referring to your files with a root-path like "/my-file.txt" (i.e. having a slash at begin),
which would result to "C:/wamp/www/my-file.txt" being requested.
Change all your paths to be relative paths, for example to "./my-file.txt" path (i.e. with both dot and slash ./),
That would change the file request to something like "C:/wamp/www/my-project/public/my-file.txt" (if your HTML file is in public directory that is).
Actually I would not recommend you using relative paths like ./myfile.txt or something else, as it can get somewhat messy when you try MVC in your code.
Instead I would recommend you set up a virtual host on your wamp machne.
Here you can read more about setting up virtual host in wamp
https://john-dugan.com/wamp-vhost-setup/

Installing Silverstripe 3.1 on subdomain

First time asking a question here but I'm really stuck.
Basically I'm trying to install a Silverstripe 3.1 cms on a subdomain as a development site, on my main domain I already have a Silverstripe 2.4 site running.
The first thing that comes up is this error, "development" is the subdomain folder.
Warning: require_once(framework/dev/install/DatabaseConfigurationHelper.php): failed to open stream: No such file or directory in /home/usr/public_html/subdomain/framework/dev/install/install.php5 on line 39
I check if the file is there and it is, then I check if the filepath is wrong because the file that is calling require_once has a full path from home/ but that can't be it because I've been able to install Silverstripe on my localhost.
I google redirecting (I've had no experience with it before) and find stuff on htaccess related to Silverstripe but none were problems that I was having, i.e. there are .htaccess files in main directory and subdomain. Not too sure if they're conflicting but I have tried RewriteEngine Off on my subdomain. I mostly leave the default Silverstripe .htaccess files as they are.
Even declaring different suPHP_ConfigPath's i.e.
main website: home/usr/public_html/
subdomain: home/usr/public_html/subdomain
At this point I look back at the error and try hacking the require_once filepath, changing it to
$_SERVER["DOCUMENT_ROOT"] . '/framework/dev/install/DatabaseConfigurationHelper.php
It mostly works but the requirements check page is void of css and any fails to GET any images
I am able to check all the requirements though passing everything but the File Permissions check:
"Does the webserver know where files are stored?" failed. Showing me the filepath it tried being the absolute path of a file prepended with the path to the subdomain. Looking at the code my hack was never intended to work.
Did I miss something? I'm not very knowledgeable with servers but I've done everything I can think of, is there anything I can do?
Hey thanks for your suggestion but I think it was meant for addon domains? I only wanted a subdomain for testing purposes.
What I ended up doing was to avoid installing Silverstripe on the server and instead install it on my laptop and then upload that to the server. It worked fine after copying the appropriate database and fixing Silverstripe's BaseURL to '/'

wamp server \ apache on Windows 7 does not load css and js files in subfolders

I've tried several versions of WAMP: 2.0 2.2 2.4 2.5 32 and 64,
and I've tried Apache stand alone on WINDOWS 7.
Root pages load but css, js and any other included files in sub-folders within a site do not load and Apace logs an access denied error.
It happens if the site is in the wamp/www folder or is an Apace alias.
I've tried gone through each step of the documentation, tried every config setting, install option, folder permissions, every idea found here and in every blog post Google returns in the search and nothing has worked. Allow all, vhosts, all those suggestions have failed.
What is up with WAMP/Apache on Windows 7? It worked fine right out of the box on my old XP machine.
thanks everyone hope someone has found a fix...
best, omcode
If you take a look into the source of the page (in your Browser), you'll quickly see that all your linked assets are using bad, non-resolving, or the wrong: path, domain, host, IP.
Possible walk trough's
check if rewrite_module is loaded if not check it and restart wamp.
Avoid relative path use absolute.
Check if the path & file-name is correct.
One of these will definitely be helpful for you.

How did my website break after deploying it?

Why did all my require_once calls that are written with paths like ../.../ this folder/thifile.php broke as soon as I deployed my website?
Are they wrong? On the localhost they were working just fine.
I got his errorfailed to open stream: No such file or directory in , and my file structure has not changed after I deployed it
Are you sure the paths point to the same places? If you have a different directory structure on your deployed site, relative paths like "../../etc" may not point to the same files.
I didn't bring my chrystal ball, so you might need to explain some more, but
You host has a different system than you (windows vs linux?), so the / and \ are not compatible?
There was some other problem (hard to guess, since you didn't provide an error)
Not enough rights to read the files
A virtual directory, so you can't go back in the structure like that, cause you're getting a different (real) dir?
Its definitely a path issue. Try going to the files u included using http://yourdomain/path/you/included

PHP CodeIgniter 404 on deploy

Oooops I did it again.
My site worked perfectly locally
My development machine is a windows WAMP2 setup
My server is a CentOS 5.5 APACHE 2.2 PHP5 seup
I'm getting a 404 on the codeigniter site that I've deployed, and I really can't make out what's wrong, so please help me find the error.
It's the root url. I haven't set up dns so it's just the ip address of the server. It was showing the standard apache page before I uploaded codeigniter. I've looked over the config file, and it looks ok. Could it be a file permissions error? i have set chmod o+rw in the whole /var/www/html dir. the error_log in the httpd shows nothing
I've tried testing if it was the mod_rewrite module, but I created a test directory with a .htaccess file with RewriteEngine ON that didn't give me an error, so that can't be it.
In codeigniter I've set the log_threshold to 4 in the config, but I don't get any log messages, so I can't really make out if it's a pre-> codeigniter error, but I really don't think it is, as it's loading my Error view, still Why isn't there any log being written, what's it about?
Any help would be extremely appreciated as I'm running on fumes to get this working...
Update
Thanks to #jondavidjohn I have discovered that hitting the controller directly IE:
http://addr/index.php/GeoController/markers/
Will provide me with a controller specific error saying:
unable to locate your model "modelname"
SOLVED
Thanks to #jondavidjohn, and #timdream for giving me the clues to solve this one. It was a naming problem, I had filenames that were camelcased, and they can only be small from what I understand now, so the ROUTE was innefective in that it lead to Site, but should've lead to site although I had a Site.php I had to change it and the route to site.php
make sure you have the correct settings in system/application/config/config.php.. pay special attention to
$config['base_url'] = "http://www.example.com";
Make sure you are putting in the root domain of your site, also check your routing config and make sure you have the correct default controller set in system/application/config/routes.php
I recently started using a fresh install of codeignitor 3.0 and had no problems on my dev server (Windows) then when I moved to my live server (Linux) I started getting a 404 error.
The reason for this is that in 3.0 you are meant to capitalise the first letter of your controllers/models and also the file name.
e.g.
class Test_model extends CI_Model {
Test_model.php
Hope this helps some people who end up here!
For reference:
http://www.codeigniter.com/userguide3/installation/upgrade_300.html
$config['uri_protocol'] could also play a part. It's default to AUTO, which looks for environment variable that contains the actual URL automatically.
I had a web app that fails when I switch to php-cgi from mod_php for my server. Changing the config to REQUEST_URI solves the issue. I found the valve by digging phpinfo() outputs, you could try to do that.
My first bet is that you were developing this and modified the .htaccess file.
HOWEVER, if you went from a Windows -> Linux system change (dev on Win, prod on nix) then you have to keep the Controller names in mind, if a file on windows was "Home.php", and you used "home.php" in the config as your default route, then it will fail.. as there is no "home.php" file.
Home.php != home.php
Linux is case sensitive. Check that out, it might be a simple thing but could cause snags.
Again I am just guessing due to lack of details.

Categories