Free Domain Server?

Problem with Server Side Includes between a domain and its subdomain

  • I'm trying to use the technique outlined http://isitvivid.com/blog/combining-your-cssjs-files-with-htaccess/ to merge my css files for my sites using SSIs, but am being plagued by [an error occurred while processing this directive]. Howdy, In my case I have one domain with 8 subdomains on it. Each of the subdomains currently use a main shared CSS file from the poppa domain, and have their own smaller local CSS file to set whatever tweaks the individual subdomains need. I'd like to merge these two together into one file server side but can't seem to get the directories worked out correctly. So right now the directory structure is is like so from my domain root: The main shared css file is located at '/home/[MAIN DOMAIN]/public_html/shared/css/shared.css' Then the subdomains have their local css at '/home/[MAIN DOMAIN]/public_html/[SUB DOMAIN]/css/local.css' So I'm adding a file into the subdomain's css folder called local.combined.css which is just the following two rules: <!--#include virtual="home/[MAIN DOMAIN]/public_html/shared/css/shared.css" --> <!--#include file="local.css" --> Unfortunately I keep getting [an error occurred while processing this directive] for the first line, which I assume means I have the directory listed wrong (but the second line with the local.css works fine). The documentation for SSIs https://my.bluehost.com/cgi/help/257 seems pretty straight forward: - Be sure to use 'virtual' instead of 'file' for files outside the same directory. - A leading forward slash automatically inserts the domain root (as listed in cpanel) so I've left off the leading forward slash here since I assume that would include the subdomain's root rather than the parent domain. But obviously I'm missing something. I've tried a number of variations hoping to hit the jackpot through trial and error, but can't seem to crack it. Any suggestions? Thanks!>>

  • Answer:

    Are the web root folders for the different domains set up with different owners?

Jezztek at Ask.Metafilter.Com Visit the source

Was this solution helpful to you?

Other answers

They shouldn't be. I created them in cpanel just by hitting the "subdomains" button and creating an appropriately named sub-directory under the parent domain's document root, so unless I mucked something up... But I suppose I should mention my VPS as a whole is setup like so: My main root account for the VPS is one domain (unrelated to this whole problem), then this whole project (the parent domain + it's subdomains) is an addon domain to my root. But in order to get SSL certs I had to split the root domain of my account and this addon domain into separate IPs / cpanels and all that, so if looking on a whole VPS basis what I have access to file wise is split between different accounts that normally can't talk to each other. I assumed that wouldn't relevant as long as all the action is taking place within one domain with a single owner / cpanel, but of course I could be wrong!

Jezztek

Are each of the subdomains in their own separate Apache configuration? With SSI you can't include files which are outside the DocumentRoot of the current website - otherwise it would be a horrible security problem, as anyone with the right to upload html files could access system files as the Apache process. The best way to do this is probably to include the CSS as <link rel="stylesheet" type="text/css" href="http://MAINSITE/shared.css" /> from each of the subsites, that way the main CSS would be included by the browser accessing the web page.

Baron Humbert von Gikkingen

Are each of the subdomains in their own separate Apache configuration? No, they are just everyday subdomains, on the same Apache configuration. The best way to do this is probably to include the CSS as from each of the subsites, that way the main CSS would be included by the browser accessing the web page. That's how I have it currently, and it works fine enough, I was just hoping to reduce the number of http requests by merging all of my css files into one (and because when something doesn't work the way I'd expect it drives me nuts until I figure out why :)

Jezztek

My experience is limited, but: - A leading forward slash automatically inserts the domain root (as listed in cpanel) so I've left off the leading forward slash here since I assume that would include the subdomain's root rather than the parent domain. If you have subdomains, it seems to me that using only a partial address instead of the whole thing would direct you to the wrong file. I have run into this when moving files around -- it can break the whole site. But it's been a while since I worked with server side includes and I don't know how to explain what I mean. If you aren't using the full address, try that. Because it seems to me that dropping something at the beginning only works when it is in the same exact file. But maybe I am parsing your comment wrong.

Michele in California

Howdy, a little clarification, basically my main issue is that it doesn't seem SSIs are following the same directory rules I had grown accustomed to for php includes. So with this directory structure lets say I had my index.php file for the subdomain, and I wanted to include the shared.inc file in the same directory of the parent domain as the shared.css file I'd write it out like this: include_once("/home/[MAIN DOMAIN]/public_html/shared/css/shared.inc"); And If I wanted to include a local.inc file as a php include_once in the same location as the local.css file is on the subdomain I'd write it like this: include_once("/home/[MAIN DOMAIN]/public_html/[SUB DOMAIN]/css/local.inc"); So I figured the SSI includes would work the same basic way with the paths being: "/home/[MAIN DOMAIN]/public_html/shared/css/shared.css" "/home/[MAIN DOMAIN]/public_html/[SUB DOMAIN]/css/local.css" Respectively, which is what I tried first, but it didn't work. In the documentation it specifically mentions the following: "That forward slash before the first directory is representative of the domain name (server root for that domain). /home#/username/public_html/ is the server root to your Main Site of your hosting account (where username is your cPanel username)." So for the shared file I tried "/shared/css/shared.css" as the path (assuming the leading forward slash would fill in the "/home#/username/public_html/" part. When that didn't work I noticed my cpanel listed just "/home#/username/" as my document root (not including the /public_html/ part, so I attempted "/public_html/shared/css/shared.css" to no avail. Finally I tried leaving the forward slash off all together to try and avoid it auto-filling any portion of the path "home/[MAIN DOMAIN]/public_html/shared/css/shared.css" with no better luck. Hope that helps clarify what I was trying to say, thanks everyone for taking the time to reply!

Jezztek

since it parses local.css fine, and interpreting that as the immediate context, have you tried using '../'s? On a phone so apologies if I get this wrong, but in this case, looks like maybe you'd try "../../shared/css/shared.css"?

juv3nal

Good call, I hadn't thought of that I'll give it a try!

Jezztek

Just tried: "../../shared/css/shared.css" "../../public_html/shared/css/shared.css" "../../../shared/css/shared.css" "../../../public_html/shared/css/shared.css" Just in case I was off by a level somewhere, but none got me what I needed. Thanks tho'!

Jezztek

That's how I have it currently, and it works fine enough, I was just hoping to reduce the number of http requests by merging all of my css files into one (and because when something doesn't work the way I'd expect it drives me nuts until I figure out why :) A static CSS file should get cached at both the server and browser levels, which is way more efficient than the convoluted scheme you're trying to implement. Apache will not by default (I believe) cache SSI pages, which pretty much defeats the goal you're trying to achieve. HTTP standards are your friend- keep it simple and don't try to reinvent the wheel!

mkultra

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.