Forum Moderators: phranque

Message Too Old, No Replies

Single domain multiple site

         

azy777

2:08 pm on Jul 20, 2009 (gmt 0)

10+ Year Member



Hi All,

I am pretty new to apache and htaccess.

I have a site which should act as two sites depending on the site id passed

A rule that redirects something like

www.test1.com/a to www.test1.com?site=1&....

www.test1.com/b to www.test1.com?site=2&....

A rule that rewrites www.abc.com & .co.in to www.test1.com/a

A rule that rewrites www.def.com & .co.in to www.test1.com/b

Any help would be greatly appreciated

Thanks :)

jdMorgan

5:08 am on Jul 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why not use subdomains instead of subdirectories or query parameters? Testing with different URLs to what you intend to use in production --or with additional query strings-- sounds like a nightmare to me.

We can help you get your own code working here, but we can't write your code for you. Please see out Forum Charter.

Jim

azy777

9:36 am on Jul 21, 2009 (gmt 0)

10+ Year Member



Thanks for that Jim.

This is the code that I am currently using

#RewriteCond %{HTTP_HOST} .
#RewriteCond %{HTTP_HOST} !^abc\.com [NC]
#RewriteRule (.*)$ [test1.com...] [R=301,L]

This works ok, but I get the following error

"Firefox has detected that the server is redirecting the request for this address in a way that will never complete."

Thanks in advance

jdMorgan

9:12 pm on Jul 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes of course, because the output URL is NOT 'abc.com', so after the client is redirected, a new request arrives and is redirected again.
The same thing would happen even if just that problem was corrected, and you would get sequential redirects, each adding another "/a" to the URL-path. This must be explicitly prevented.

RewriteCond %{HTTP_HOST} ^(www\.)?abc\.(com¦co\.in) [NC]
RewriteCond $1 !^a/
RewriteRule ^(.*)$ http://www.test1.com/a/$1 [R=301,L]

Important: Replace the broken pipe "¦" character with a solid pipe character before use; Posting on this forum modifies the pipe characters.

Jim

azy777

7:07 am on Jul 22, 2009 (gmt 0)

10+ Year Member



Now I know exactly what I was missing .

Works a breeze. Thank a million Sir :)