Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite new domain name

keeping old domain and point new to a particular folder

         

pauls

4:15 pm on Feb 17, 2006 (gmt 0)

10+ Year Member



i have www.domain1.com
and there is a forum located on www.domain1.com/forum/

now I have www.domain2.com pointing to this domain1.com aswell.

now I want to have a rewrite rule that willl move requests for www.domain1.com/forum to the new domain, and look like either www.domain2.com or www.domain2.com/forum/

Any ideas? I'll post some of my attempts here later, I was able to do the first bit, so that www.domain2.com calls www.domain1.com/forum . I will post that once I get my FTP login working again.

My expertise is in CSS, so I am looking forward to helping some people out here in the future!

thanks,
pauls

lammert

5:48 pm on Feb 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



First of all welcome to WebmasterWorld!

To help in your efforts, you may want to look in the forum library [webmasterworld.com]. You can find a lot of interesting information about mod_rewrite there.

Lammert

pauls

6:06 pm on Feb 17, 2006 (gmt 0)

10+ Year Member



#new from paul
# Rewrite xyz domain to subfolder
RewriteCond %{HTTP_HOST} ^www\.domain2\.com
RewriteCond %{REQUEST_URI}!/forum/
RewriteRule (.*) /forum/$1 [L]
#and for people who forget www
RewriteCond %{HTTP_HOST} ^domain2\.com
RewriteCond %{REQUEST_URI}!/forum/
RewriteRule (.*) /forum/$1 [L]

this was the first bit, but I don't know if this is complete.

but now I want a redirect from domain1.com/forum to domain2.com or domain2.com/forum

I think this might create a infinite loop as they point to the same folder.

jdMorgan

6:57 pm on Feb 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




# Rewrite xyz domain or www.xyz domain to subfolder
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com
RewriteCond %{REQUEST_URI} !/forum/
RewriteRule (.*) /forum/$1 [L]

You can usually prevent looping in such a case by using RewriteCond %{THE_REQUEST} to examine the client-requested URL-path. This is unaffected by internal rewrites.

Jim

jdMorgan

7:03 pm on Feb 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually, a rewrite from domain1 to domain2 should not loop anyway, since your rules are conditioned upon the doamin being domain2.

A better solution to the missing www problem is to redirect from non-www to www -- or vice-versa. This also helps from an SEO perspective -- No use spreading your PageRank or link popularity accross what search engines see as two separate domains...

> but now I want a redirect from domain1.com/forum to domain2.com or domain2.com/forum

Redirect from domain1.com/forum to domain2, then let your internal rewrite take care of adding /forum on domain2. Otherwise, the /forum subdirectory path will be 'exposed' to users and to search engines. I don't think you'd want that.

Jim