Joomla! 1.5.23 on Mac not using relative links - php

I'm on a Mac 10.8.4, running Joomla! 1.5.23 out of the Mac's default Apache 2 instance.
Everything's been fine for six months or so, but today when I tried to access my Joomla site at:
http://localhost/~george/mysite
I get 404 errors for all the linked files from index.php
Inside index.php I link to JS and CSS files e.g.:
<script src="templates/mytemplate/scripts/custom.js"></script>
<link rel="stylesheet" type="text/css" href="templates/mytemplate/css/style.css" />
and Chrome shows me that these links are resolving to:
http://localhost/templates/mytemplate/scripts/custom.js
as opposed to:
http://localhost/~george/mysite/templates/mytemplate/scripts/custom.js
the latter URL returns the document as per usual.
Any ides what's been changed in Apache, Joomla, or elsewhere that's causing this to happen, and how to revert it?

To fix this, you should use the Joomla coding stansards to import css and js files, like so:
$doc = JFactory::getDocument();
$doc->addScript( JUri::root() . "templates/mytemplate/scripts/custom.js" );
$doc->addStylesheet( JUri::root() . "templates/mytemplate/css/style.css" );
Just on a side note, I would recommend upgrading to Joomla 2.5+ as there are security issues with 1.5, however if you're unable to do tgis, please atleast upgrade the to the latest of the 1.5 series, which is 1.5.26
Hope this helps

The actual cause in my case was an incorrect setting for $live_site in configuration.php, but your points are all valid.
Thanks

Related

Laravel cannot find stylesheets and nor can I

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.

phpspreadsheet which is installed on subdirectory by composer, not working

I installed phpspreadsheet on my subdirectory banana(OMG.com/fruits/banana).
And tried to open its sample page.(banana/vendor/phpoffice/phpspreadsheet/samples/index.php)
But it didn't work.
So I followed source, and changed css and js path on Header.php like this.
From <link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css"/>
To <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"/>
Then the sample page (samples/index.php) shows correctly. So I clicked its sample menu. But it didn't work again. Error code was 404. I opened sample/index.php and observed sample menu link. The link was this.
OMG.com/Autofilter/10_Autofilter.php
But 10_Autofilter.php was not in there. it was in here.
OMG.com/fruits/banana/vendor/phpoffice/phpspreadsheet/samples/Autofilter/10_Autofilter.php
I found the reason is path. But I didn't know how to solve. I thought the easiest way is install phpspreadsheet by composer on root directory. But I thought again and it's not gonna success. because if I install phpspreadsheet on root directory, the sample pages will be on here.
OMG.com/vendor/phpoffice/phpspreadsheet/samples/Autofilter/10_Autofilter.php
But the link was like this.
OMG.com/Autofilter/10_Autofilter.php
Maybe this can be easy fundamental problem. But I don't know how.
Help...
PS. I installed phpspreadsheet on here.
OMG.com/fruits/banana> composer require phpoffice/phpspreadsheet
PHPSpreadsheet is a library, intended to be used by your programs, and not directly accessible through a web interface.... and the examples are written to be run from the command line (if you want to run them).
You need to create a script in your normal home directory that includes the vendor autoloader, and then the classes in PHPSpreadsheet will be accessible to your script

Having problems with CakePHP 3 links due to shared hosting DocumentRoot

So, I've searched and found some simillar questions, but none of the answers worked for me.
Let me explain the situation. I've built a CakePHP 3 and it works great in my local machine. When I finally deployed to the server, things got really weird.
Basically, when I use the link() or css() or other methods of the Html Helper, CakePHP adds the whole path (starting from the root). So, I'd write something like:
<?= $this->Html->css( 'main.css' ) ?>
and the output should be:
<link rel="stylesheet" href="/css/main.css"/>
but what I'm getting is this:
<link rel="stylesheet" href="/var/www/html/mydomainname.net/web/css/main.css"/>
I did some research on the hosting company FAQs and documentation, and I found out that the Apache DocumentRoot is set to the '/', which is of course not desired, since CakePHP requires it to be set to the app's web root folder. The thing is, since this is a shared hosting environnment, I cannot change it!
Any ideas?
According to the docs:
This method of CSS inclusion assumes that the CSS file specified resides inside the /app/webroot/css directory if path doesn’t start with a ‘/’.
As a workaround then, you might be able to try:
<?php $this->Html->css('/css/main.css') ?>
to prevent cake from making assumptions.
From here: http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::css
Well, the solution I've found was simply to not use Html Helper methods such as link() and css(), and use plain good old html instead. The ideal would probably edit Apache settings and make DocumentRoot point to the webroot folder in my app, but my hosting company support was not as helpful as I'd wished them to be.

not found css file in cakephp without rewrite module

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.

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