Forum Moderators: phranque

Message Too Old, No Replies

Subdomain redirection (URL rewriting)

Need help with mod rewrite

         

Paullezzz

12:45 pm on Oct 15, 2007 (gmt 0)

10+ Year Member



Hello,

I am quite new here, and new with .htaccess, but for my work I have a
really burning question, can one of you all help me with this please?

i have got 2 domains:
- older-domain.nl (Windows server, html, asp pages)
- newer-domain.nl (Free BSD server, php pages)

What I would like to get is the following:

The website on older-domain.nl can not be modifies yet, is really old but it
will be better in the future. This website has to two subdomains,
metoc and regact.

But these subdomains are located at the second domain,
newer-domain.nl.

I have made folders in htdocs on the second domain like bellow:
- newer-domain.nl/metoc
- newer-domain.nl/regact

With some help from the hosting provider, we wrote this .htaccess file:


RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} metoc.older-domain.nl
RewriteCond %{REQUEST_URI} !metoc/
RewriteRule ^(.*)$ metoc/$1 [L]

On the first eye this worked great, but we are using Joomla as CMS system.
So I adjusted the configuration.php file to set the right directions.

So when I refreshed, I saw a website without a CSS file and other images.
Now I think it is because the .htaccess doesn’t go trough all folders,
because I tried to reach the templates CSS file by putting this in the URL field of Firefox:

http://metoc.older-domain.nl/templates/metoc/css/template_css.css
( And this should work, but it doesn’t. 404 Error )

http://www.newer-domain.nl/metoc/templates/metoc/css/template_css.css
( This is the old URL of the document and it still works )

I hope you understand what I am trying to achieve.

Thanks in advance, Paul den Hertog

(sorry for the bad english)

[edited by: jdMorgan at 2:16 pm (utc) on Oct. 15, 2007]
[edit reason] examplified, de-linked [/edit]

jdMorgan

2:26 pm on Oct 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



http://metoc.older-domain.nl/templates/metoc/css/template_css.css
( And this should work, but it doesn’t. 404 Error )

I would not expect this URL to work, for several reasons.

First, it already contains "metoc" in the URL-path, so the RewriteCond exclusion will prevent your rule from being applied.

Second, your rule has no provision to allow 'metoc' to be inserted *after* "templates" and before "css".

Also, you need to look into how requests are 'sent' to Joomla; If they are proxied to a back-end server or are rewritten, then your rule must take that into account, or you may need a modified 'copy' of the rule in the /templates subdirectory.

Finally, be aware that it is the browser that resolves relative links on your pages. So links to images, CSS, included JavaScript files, etc., will need to be either server-relative or absolute. Or you will need to rewrite those requests, when received, to the correct path. To be clear, use <img src="/images/logo.gif"> or <img src="http://example.nl/images/logo.gif"> instead of <img src="images/logo.gif">

Jim

Paullezzz

6:56 am on Oct 16, 2007 (gmt 0)

10+ Year Member



First of all thanks for your reaction.

Ok, let me get it right, all I have to do is manually code the paths in the template and when i use images i have to use the new url, or the old url.

I think i have to use the old url, because the new one wont work.

But do you think this isn’t possible, or do you now for sure?

Isn’t there a way to get htaccess work at several subfolders to?

( By the way, i saw that you modded my post. Probably because I am not allowed to post real links? )

Paul