LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache2 includes directive for images, css, and js (http://www.linuxquestions.org/questions/linux-server-73/apache2-includes-directive-for-images-css-and-js-685283/)

Russianspi 11-21-2008 06:51 PM

Apache2 includes directive for images, css, and js
 
Hi. So, I feel like I've been banging my head against a wall for the last few days, so I'll ask for some help. I have a whole mess of php based reports that I am trying to organize. These reports live on an apache2 server. There were originally 5 reports for some basic sales data for the company I work for. Well, 5 turned into 6, and the 12, and before I knew it (a year and a half later) there are hundreds of reports. Many of them share large bits of code, and quite a few of them are just duplicates of each other. Many others are outdated and no longer used. Along the way, we've started using a javascript calendar, company logos, css, etc. The trouble is, many of these are duplicated as well.

I have created a new virtual host, and I want to keep from duplicating content. I made directories for outside libraries (like my js calendar), includes (for my php bits that I want to keep from duplicating), images, and css. My goal is that my "reporting suite" be maintainable and portable (with as few changes as possible).

To cut my story down, I'll skip to the part where I created a php_value include_path "/path/to/application" in my virtualhost directive. My php include files load up fine relative to my include_path, html code in those files referencing javascript, css, and images all ignore this path. So, I wind up with broken images, no css, and no js? Is there a way to make all of this work?

Wim Sturkenboom 11-23-2008 06:41 AM

As far as I know images, css and js should be accessible by the browser (client) and therefore they should be in (a subdirectory of) the document root.

Russianspi 11-24-2008 11:50 AM

Clarification
 
I realized after posting this (and seeing your reply) that this needs a little clarification from me. When my included php references js, css, and images, it seems to reference them relative to the main page (the one calling the included file). This doesn't work for me, because I need to be able to use these included files from anywhere in my "application". I can't seem to make fully qualified paths work for js/css (particularly css images). Am I missing something?

Wim Sturkenboom 11-24-2008 11:06 PM

Use an absolute path in your pages

Code:

<head>
<title>Command Centre Incident Logging System - login</title>
<link rel="stylesheet" href="/css/btd2.css" type="text/css">
<link rel="stylesheet" href="/css/menu.css" type="text/css">
<script language="javascript" type="text/javascript" src="/js/datetimepicker.js"></script>
</head>

So your web structure will look something like:
Code:

http://reports
          |
          +----report1.php
          +----report2.php
          |
          +----css
          |    +----btd2.css
          |    +----menu.css
          |
          +----js
          |      +----datetimepicker.js
          |
          +----images
                +----image1.png
                +----image2.png


Russianspi 11-25-2008 02:30 PM

Wow. Wim, that did it. I'm bummed I wasted a few days on a couple of leading slashes, but it's done. Thanks so much! You're a lifesaver. We can mark this one solved.

Wim Sturkenboom 11-25-2008 09:39 PM

Glad I could help.

You can mark the thread as solved using tags (e.g. in your opening post)

WimS


All times are GMT -5. The time now is 12:02 PM.