0

Actually I have a domain - domainone.com

I have created a subdomain cname of anoter domain as

abc.domaintwo.com - CNAME as - domainone.com

so that I can use the js and css files e.g domainone.com/js/jquery.js files as abc.domaintwo.com/js/jquery.js

SO Far everything is FINE, no issues at all.

Problem:

I have a custom 404 page for domainone.com and now when that abc.domaintwo.com goes 404 same page appears which i don't want. Any help is appreciated.

Htaccess of domainone.com:

ErrorDocument 404 /404/

All i want is to have different 404 for both.....

Notes: Don't have access to shell for symlinks or alias as I am on shared hosting.

Dai
  • 141,631
  • 28
  • 261
  • 374
Luckyy
  • 1,021
  • 4
  • 15
  • 29

1 Answers1

1

For what you are trying to do, you will need to use PHP. It cannot be done in your .htaccess. The ideal place would be the virtual hosts file, but sounds like you don't have access.

You should separate the web roots apart from each other, and then mod rewrite:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} abc.domaintwo.com$ [NC]
RewriteRule ^(js|css)/(.*) http://www.domain.com/$1/$2 [L,PT] 

This should redirect http://abc.domaintwo.com/js/* and css/* to www.domain.com/js and css/

Note: it is untested, but should work if my memory serves correctly.

Mike Mackintosh
  • 13,917
  • 6
  • 60
  • 87
  • Hi thanks for the reply abnd I tried that but then if i open that file in new tab that again points to the domainone.com – Luckyy Jun 21 '12 at 15:44
  • No friends, actually http://abc.domaintwo.com/js/* is working fine but it is working as redirection and i dont want to show the url in browser as www.domain.com/js – Luckyy Jun 21 '12 at 17:17
  • anyway thanks buddy, I found wat i wanted basically to have two different 404s... – Luckyy Jun 21 '12 at 17:49
  • Can you post your solution for others? – Mike Mackintosh Jun 21 '12 at 17:57
  • yeah sure, Nothing much just checked the domain name of 404 page of domainone.com...if found abc.domaintwo.com then showing somehting else/or just redirect . :) I meant... if ( $_SERVER['HTTP_HOST'] == 'abc.domaintwo.com' ) – Luckyy Jun 21 '12 at 18:00