Page 1 of 1

.htaccess on multiple domains included pretty url

Posted: Thu Jun 03, 2010 8:59 am
by brentnl
Hello,

For a customer I'm implementing a new layout included with CMSMS. He has one hosted domain www.domain1.nl and 7 forwarded domains. In the current situation , if you go to www.domain2.com you get forwarded to the content of domain1 but the URL remains domain2.com.

I want to write a htaccess file which changes all of the 7 forward-domains to the main-hosted-domain.

I've started with the htaccess file, but I also want 'www' in front of it, no mather what URL you choise.. (domain3.com, www.domain3.com http://domain4.com http://www.domain5.com, the all should redirect to www.domain1.com)

Code: Select all

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

 # Link to http://website.com then redirect to http://www.website.com

RewriteCond %{HTTP_HOST} ^domain1\.nl [NC]
RewriteRule ^(.*)$ http://www.domain1.nl/$1 [L,R=301] 

RewriteCond %{HTTP_HOST} ^domain2\.nl [NC]
RewriteRule ^(.*)$ http://www.domain1.nl/$1 [L,R=301] 

RewriteCond %{HTTP_HOST} ^domain3\.nl [NC]
RewriteRule ^(.*)$ http://www.domain1.nl/$1 [L,R=301] 


  # 301 Redirect all requests that don't contain a dot or trailing slash to
  # include a trailing slash
  # except for form POSTS
  # RewriteCond %{REQUEST_URI} !/$
  # RewriteCond %{REQUEST_URI} !\.
  # RewriteCond %{REQUEST_METHOD} !POST$
  # RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
 
  # Rewrites urls in the form of /parent/child/
  # but only rewrites if the requested URL is not a file or directory
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.+).html$ index.php?pagina=$1 [QSA] 
but if I go the URL http://domain1.com I got an error which says: Firefox can't find the server on www.^domain1.nl
And I can't get the other URL's to work as well..

Re: .htaccess on multiple domains included pretty url

Posted: Sun Jun 13, 2010 11:27 am
by kermit
i use the following....

Code: Select all

RewriteCond %{HTTP_HOST} ^domain2.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain2.com$
RewriteRule ^(.*)$ http://www.domain1.com/ [R=301,L]
(cpanel automatically added those when i set up the redirects)

it redirects requests for any page (not just root page) at domain2.com to the *root* page of the main domain, domain1.com

put it right after

Code: Select all

RewriteEngine on
RewriteBase /