Forum Moderators: phranque

Message Too Old, No Replies

Multiple domains on same server

Using mod_rewrite to rewrite to different folders

         

Leggie

9:50 pm on Nov 12, 2008 (gmt 0)

10+ Year Member



Hi there,

I'm in the situation of having two domains on the same host. I've been trying to use mod_rewrite with limited success. I'm trying to send one domain to one folder and the other domain to another.

Now the file is working in that the links are pointing to the right files/folders, but the server seems to be 301 redirecting the URLs rather than rewriting them. The new URLs appear in the browser address bar, and the server seems to be sending a 301 redirect, according to web-sniffer.net.

Anyway, if you've any ideas why my code isn't working, I'd be glad to hear them. Apologies in advance for any obvious errors.

Here's what I've got in my .htaccess file:

RewriteCond %{HTTP_HOST} myfirstdomain.com
RewriteCond %{REQUEST_URI} !^/folder1
RewriteRule ^(.*)$ ga/$1 [L]

RewriteCond %{HTTP_HOST} myseconddomain.co.uk
RewriteCond %{REQUEST_URI} !^folder2
RewriteRule ^(.*)$ sp/$1 [L]

Thanks!

Leggie

jdMorgan

10:05 pm on Nov 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The folder tested aganst REQUEST_URI and the RewriteRule substitution folder must match in order to avoid an infinite loop.

Other than that, it seems that you have additional mod_alias, mod_rewrite, mod_proxy, or mod_dir code on the server --either in those subfolders or in one of the server config files-- that is generating an external redirect, as neither of those rules you posted will do that.

BTW, you may find the Live HTTP Headers add-on for Firefox to be quite useful; It provides convenience and a level of detail provided by few on-line headers checkers.

Jim

Leggie

10:22 pm on Nov 12, 2008 (gmt 0)

10+ Year Member



The folder tested aganst REQUEST_URI and the RewriteRule substitution folder must match in order to avoid an infinite loop.

Sorry, you're quite right - in practice, they do - I forgot to edit the ones in the above example's RewriteRule as I tried to substitute fake folder names for a non-specific example!

As for your other point, thanks. I suppose I'd better contact my host and ask what's up.

Thanks again.