Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-11-17 18:04:11

zachphillips
New Member
Registered: 2011-11-17
Posts: 7

path_to_site/document root don't match - how to set the document root?

I’m sorry to be resigning myself to a forum post, but I am at my wit’s end.

I have spent 5 hours on this. I have exhausted everything mentioned anywhere in the forums or on Google, and on my own tried to tweak the .htaccess file and edit variables in the database. (EVERYTHING IS BACK TO DEFAULTS, I PROMISE)

I need to be able to set the document root to be the same as the path_to_site. Every CSS and image link is broken because of this problem, and the thing that makes this so frustrating is I can’t simply set doc_root in my config file and just fix it. I tried, and apparently that variable has been deprecated.(?)

I even went on IRC to the #textpattern channel and one person showed up after an hour and they didn’t have any idea what was causing the problem (though I really appreciate them trying to help).

I can access my database and change anything. I am desperate for an answer. Where in the world is it getting this broken Document root from?

Textpattern version: 4.4.1 (r3575)
Last Update: 2011-08-08 14:00:03/2011-11-17 14:12:29
Document root: /var/www/vhosts/thekitchen.co/clients
$path_to_site: /var/www/vhosts/thekitchen.co/clients/challengeprogram
Textpattern path: /var/www/vhosts/thekitchen.co/clients/challengeprogram/textpattern
Permanent link mode: year_month_day_title
Temporary directory path: /var/www/vhosts/thekitchen.co/clients/challengeprogram/textpattern/tmp
Site URL: clients.thekitchen.co/challengeprogram
PHP version: 5.2.13
GD Image Library: version bundled (2.0.34 compatible), supported formats: GIF, JPG, PNG
Server TZ: UTC
Server Local Time: 2011-11-17 17:46:26
DST enabled?: 0
Automatically adjust DST setting?: 0
Time Zone: America/New_York (-18000)
MySQL: 5.0.77
Locale: en_US.UTF-8
Server: Apache/2.2.3 (CentOS)
Apache version: Apache/2.2.3 (CentOS)
PHP Server API: apache2handler
RFC 2616 headers: 
Server OS: Linux 2.6.31-302-rs
Admin-side theme: classic 4.4.1

.htaccess file contents: 
------------------------
#DirectoryIndex index.php index.html

#Options +FollowSymLinks
#Options -Indexes
#ErrorDocument 403 default

<IfModule mod_rewrite.c>
	RewriteEngine On
	#RewriteBase /relative/web/path/

	RewriteCond %{REQUEST_FILENAME} -f [OR]
	RewriteCond %{REQUEST_FILENAME} -d
	RewriteRule ^(.+) - [PT,L]

	RewriteCond %{REQUEST_URI} !=/favicon.ico
	RewriteRule ^(.*) index.php

	RewriteCond %{HTTP:Authorization}  !^$
	RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

#php_value register_globals 0

------------------------

Offline

#2 2011-11-17 18:45:00

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: path_to_site/document root don't match - how to set the document root?

Textpattern itself doesn’t set document root, and changing the setting at Textpattern’s end wouldn’t really do anything good. Server does control the document root, and PHP gives Textpattern the value. In other words, the path in the diagnostics report is Apache’s document root. To change server’s document root, you will need to change Apache’s configuration.

Offline

#3 2011-11-17 18:55:20

zachphillips
New Member
Registered: 2011-11-17
Posts: 7

Re: path_to_site/document root don't match - how to set the document root?

Thank you so much for the fast response.

So does this mean I can only run one instance of Textpattern per subdomain?

Here’s my apache conf

<VirtualHost *:80>
    DocumentRoot /var/www/vhosts/thekitchen.co/clients
    ServerName clients.thekitchen.co
    ServerAlias www.clients.thekitchen.co
    DirectoryIndex index.php index.html index.htm index.shtml

  <Directory /var/www/vhosts/thekitchen.co>
        AllowOverride All
   </Directory>
</VirtualHost>

Offline

#4 2011-11-17 19:06:57

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: path_to_site/document root don't match - how to set the document root?

zachphillips wrote:

So does this mean I can only run one instance of Textpattern per subdomain?

No, of course not. Textpattern isn’t tied to limitations like that. The document root isn’t even used for your links and changing it wouldn’t fix your image issues.

The thing that is used for URLs, is your site’s URL… and that’s it. When working with sub directory, make sure you are using correct relative URLs, and tags that generate absolute URLs. As you are having image issues, it sounds that you are merely just using incorrect path structure (as in starting the paths in CSS files with slash etc).

Last edited by Gocom (2011-11-17 19:08:39)

Offline

#5 2011-11-17 19:11:50

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,699
Website

Re: path_to_site/document root don't match - how to set the document root?

And if you change the following line?

DocumentRoot /var/www/vhosts/thekitchen.co/clients/challengeprogram

… but I guess that changes your entire subdomain position…

It looks to me like you have txp installed in the subdirectory /challengeprogram but then output urls (without using <txp:site_url />) that are relative to the doc_root so it will obviously not find the images. I can see them if I add /challengeprogram/ manually to the url.

Further things to try:

  • In your .htaccess file, try uncommenting (remove the #) the line RewriteBase and specifying your relative path, e.g. RewriteBase /challengeprogram (as described here)
  • Use <txp:site_url /> to construct your links to images and if you have the subdirectory set it should match

Last edited by jakob (2011-11-17 19:13:41)


TXP Builders – finely-crafted code, design and txp

Offline

#6 2011-11-17 19:12:39

zachphillips
New Member
Registered: 2011-11-17
Posts: 7

Re: path_to_site/document root don't match - how to set the document root?

Thanks so much again.

I promise you I’m not. The site url is correct. But then go to http://clients.thekitchen.co/challengeprogram/ and do a view source and all of the links are reflecting the incorrect Document root.

As you can see from my <head>, the links are correct, relative to the site url.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<link rel="stylesheet" href="/stylesheets/main_home.css" type="text/css" media="screen" charset="utf-8" />
       <link rel="shortcut icon" href="http://www.challengestaging.com/favicon.ico" />
       <link rel="alternate" type="application/rss+xml" title="The Challenge Program" href="rss" />
	<script src="/javascript/prototype.js" type="text/javascript" charset="utf-8"></script>
	<script src="/javascript/scriptaculous/scriptaculous.js" type="text/javascript" charset="utf-8"></script>
	<script src="/javascript/house_dropdown_menus.js" type="text/javascript" charset="utf-8"></script>
	<script src="/javascript/preloader.js" type="text/javascript" charset="utf-8"></script>
	<script src="/javascript/fader.js" type="text/javascript" charset="utf-8"></script>
	<script src="/javascript/cab_rotator.js" type="text/javascript" charset="utf-8"></script>


		<style type="text/css" media="screen">
			#more_slideshow_images  {
				display:none;
			}
		</style>

	<title>The Challenge Program</title>

</head>

Offline

#7 2011-11-17 19:20:15

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: path_to_site/document root don't match - how to set the document root?

zachphillips wrote:

As you can see from my <head>, the links are correct, relative to the site url.

All those URLs are absolute, as such pointing to incorrect location. For example /stylesheets/main_home.css will need to be either:

  • <txp:site_url />stylesheets/main_home.css
  • /challengeprogram/stylesheets/main_home.css

Paths in CSS, like background: transparent url(/images/purple-bullet.gif) no-repeat;, can be either:

  • As relative: ../images/purple-bullet.gif
  • Absolute: /challengeprogram/images/purple-bullet.gif

Last edited by Gocom (2011-11-17 19:27:26)

Offline

#8 2011-11-18 15:07:42

zachphillips
New Member
Registered: 2011-11-17
Posts: 7

Re: path_to_site/document root don't match - how to set the document root?

Okay… I see how I can make it work now with <txp:site_url /> but how is that not a problem with a false document root?

This site lives at the directory challengeprogram/. So why are links not relative to that directory? They would be if it were not in a sub-directory.

So I’ll use <txp:site_url />, but in the hundred websites I’ve worked on, I’ve never had to “pretend” I wasn’t in a subdirectory with respect to relative links.

Thank you for helping me fix my problem, though I still think <doc_root> should be a variable, and avoid this whole mess in the first place.

Offline

#9 2011-11-18 17:03:34

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: path_to_site/document root don't match - how to set the document root?

zachphillips wrote:

So why are links not relative to that directory?

All the links you used are absolute. When you start your path or URL with a slash, it tells that it needs to look for the item from the root (as in from client’s, web browser’s, perspective, not from server’s).

For example /stylesheets/main_home.css translates to http://clients.thekitchen.co/stylesheets/main_home.css as the path used is not relative. Those absolute URLs can only work when the site is installed at the root of the domain, but not when in a sub-directory.

As far as document root goes, it is for your server’s internal functions, and doesn’t directly effect Textpattern, nor web browsers connecting to your site, and you can’t change it at Textpattern’s end. Only function of document root is to tell where the virtualhost’s (as in domain’s) content is located (internally on the server).

Last edited by Gocom (2011-11-18 17:10:14)

Offline

#10 2011-11-18 17:22:23

zachphillips
New Member
Registered: 2011-11-17
Posts: 7

Re: path_to_site/document root don't match - how to set the document root?

Okay. So I removed the first slash and it’s fixed. Thank you. That is all I needed.

There is no need for the <txp:site_url /> tag or anything else. Just remove the first slash, which tells the site to look absolutely from the domain root, and doesn’t work when you have textpattern running in a subdirectory.

Wow, I can’t believe I’m the only one who’s ever had this problem… I hope this thread can be useful to someone in the future.

Thank you so much for your help. You guys are the best.

Offline

#11 2011-11-18 17:31:23

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,536
Website GitHub Twitter

Re: path_to_site/document root don't match - how to set the document root?

Hi

A problem with relative url is that is not working in a category or a section link when you are in url scheme different from messy:
ex: yousite.com/thesection will not find images when they are set in relative url!

Offline

#12 2011-11-18 17:35:14

zachphillips
New Member
Registered: 2011-11-17
Posts: 7

Re: path_to_site/document root don't match - how to set the document root?

Ahhh… So I should use the site_url tag then…

I suppose it’s just as well. It’s just not generally as clean.

Offline

Board footer

Powered by FluxBB