Problem with linked files

Using a single web hosting account to host multiple sites

Problem with linked files

Postby stk » Mon Mar 24, 2008 1:24 am

Hi,
I'm using the following rewrite code suggested by richardk some time ago on one server to point multiple parked domain names to their own directory within the "vhost" dir:

Code: Select all
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/vhost/domain%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^(.*)$ /vhost/domain/$1 [QSA,L]


This is working perfectly.

However, I'm trying to set this up on another host (same hosting company / configuration) without the "vhost" dir (ie /domain/ is a directory in the root dir) and all linked files (images, css) are 404ing.

Any help greatly appreciated.

Thanks, sk.
stk
 
Posts: 10
Joined: Mon May 28, 2007 12:44 am

Postby richardk » Mon Mar 24, 2008 12:34 pm

What are the paths to the files like? What is your exact mod_rewrite?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby stk » Mon Mar 24, 2008 2:14 pm

Thanks for the reply.
The exact MR is this:
Code: Select all
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?antripodean\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/antripodean%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?antripodean\.com$ [NC]
RewriteRule ^(.*)$ /antripodean/$1 [QSA,L]


The links to the css / images are relative, eg:
Code: Select all
assets/css/layout.css


The path to the files themselves, eg:
Code: Select all
(webroot)/antripodean/assets/css/layout.css


Is it because the browser is looking for layout.css in the root dir, rather than the /antripodean/ subdirectory?

Thanks.
stk
 
Posts: 10
Joined: Mon May 28, 2007 12:44 am

Postby richardk » Tue Mar 25, 2008 12:13 pm

It is looking in your document root, but it shouldn't be. Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{DOCUMENT_ROOT}/antripodean%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.*)$ /antripodean/$1 [QSA,L]

Do you have any mod_rewrite in your sub directories?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby stk » Fri Mar 28, 2008 5:36 pm

Sorry it took a few days to get the time to try this one out.

The rewrite above didn't work - It caused the server to serve documents in xtr.com/antripodean/ when one hit xtr.com/ rather than the other way round (serve xtr.com/antripodean/ when viewing antripodean.com).

I did have the following rewrite in the /antripodean directory, but have since removed it with no change in behavior.

Code: Select all
# Direct release URL
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^releases/([0-9A-Za-z-]+)/?$ ./releases/release.php?CatNum=$1 [QSA,L]


thanks again,
sk
stk
 
Posts: 10
Joined: Mon May 28, 2007 12:44 am

Postby richardk » Sun Mar 30, 2008 10:43 am

The rewrite above didn't work - It caused the server to serve documents in xtr.com/antripodean/ when one hit xtr.com/ rather than the other way round (serve xtr.com/antripodean/ when viewing antripodean.com).

Right, you need the
Code: Select all
RewriteCond %{HTTP_HOST} ^(www\.)?antripodean\.com$ [NC]

lines.

I have no idea why this is happening. Do you have any other settings that could conflict with this? Could you get a RewriteLog?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby stk » Sun Mar 30, 2008 3:53 pm

Mhh, that didn't seem to make a difference. Very strange.
If you view source at www.antripodean.com you see that the css etc is linked as: "assets/css/layout.css", etc. as you can see, this does exist.

I've posted my entire .htaccess for xtr.com below, if you can see any possible conflicts.

Code: Select all
Options +FollowSymLinks
RewriteEngine On

#ErrorDocument 404 /404.php

####################################################
# Antripodean.com rewrites
####################################################

RewriteCond %{HTTP_HOST} ^(www\.)?antripodean\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/antripodean%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?antripodean\.com$ [NC]
RewriteRule ^(.*)$ /antripodean/$1 [QSA,L]

####################################################
# XTR.com Rewrites
####################################################

# Redirect old release & artist pages
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?xtr\.com$ [NC]
RewriteCond %{REQUEST_URI} ^(/.+)\.php$ [NC]
RewriteRule ^catalog/.+\.php$ %1/ [NC,R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?xtr\.com$ [NC]
RewriteCond %{REQUEST_URI} ^(/.+)\.php$ [NC]
RewriteRule ^artists/.+\.php$ %1/ [NC,R=301,L]

# Direct release URL
RewriteCond %{HTTP_HOST} ^(www\.)?xtr\.com$ [NC]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^catalog/([0-9A-Za-z-]+)/?$ ./catalog/release.php?CatNum=$1 [QSA,L]

# Direct artist URL
RewriteCond %{HTTP_HOST} ^(www\.)?xtr\.com$ [NC]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^artists/([0-9A-Za-z_-]+)/?$ ./artists/artist.php?Name=$1 [QSA,L]


To reiterate, the site should work as follows:

Code: Select all
www.xtr.com => docroot/
www.xtr.com/catalog/AlphaNumWithDashes/ => docroot/catalog/release.php?CatNum=AlphaNumWithDashes
www.xtr.com/artists/AlphaNumWithDashes/ => docroot/artists/artist.php?Name=AlphaNumWithDashes
(The above is currently working fine)
www.antripodean.com => docroot/antripodean/
www.antripodean.com/catalog/AlphaNumWithDashes/ => docroot/antripodean/catalog/release.php?CatNum=AlphaNumWithDashes
www.antripodean.com/artists/AlphaNumWithDashes/ => docroot/antripodean/artists/artist.php?Name=AlphaNumWithDashes



My sincere thanks for sticking with this.. I'm slowly learning regex, but it's a long and rocky path ;)

As an aside, I don't know if you accept donations for your work here, but if so I'd be more than willing to reward your help, either monetarily or with merchandise (and chance you're into avant-garde jazz or experimental music?).

Cheers,
sk
stk
 
Posts: 10
Joined: Mon May 28, 2007 12:44 am

Postby richardk » Tue Apr 01, 2008 2:48 pm

Ok, you have /assets and /antripodean/assets, right? Then try
Code: Select all
Options +FollowSymLinks

instead of
Code: Select all
Options +FollowSymLinks -MultiViews
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby stk » Tue Apr 08, 2008 12:26 am

richardk wrote:Ok, you have /assets and /antripodean/assets, right? Then try
Code: Select all
Options +FollowSymLinks

instead of
Code: Select all
Options +FollowSymLinks -MultiViews


My current htaccess has only Options +FollowSymLinks.
Just tried both, neither solve the problem.

What's weird is that I'm running a similar htaccess on my personal site (same hosting company/configuration), to redirect various parked domains to subdirectories, and all is fine there.

Code: Select all
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?antisound\.net$ [NC]
RewriteCond %{DOCUMENT_ROOT}/vhost/antisound%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?antisound\.net$ [NC]
RewriteRule ^(.*)$ /vhost/antisound/$1 [QSA,L]

.. and so on for each domain.


Thinking it may be time to file a support request, is it possible that something is amiss at the host end?
Skye
stk
 
Posts: 10
Joined: Mon May 28, 2007 12:44 am

Postby richardk » Wed Apr 09, 2008 1:56 pm

Thinking it may be time to file a support request, is it possible that something is amiss at the host end?

I only know of MultiViews that causes problems like this, but you could ask.

What's weird is that I'm running a similar htaccess on my personal site (same hosting company/configuration), to redirect various parked domains to subdirectories, and all is fine there.

But are you using any matching directory names like /assets and /antripodean/assets?

Can you confirm that you have /assets and /antripodean/assets and that does not happen if you rename /assets.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 24 guests

cron