.htaccess on multiple domains included pretty url

General project discussion. NOT for help questions.
Post Reply
brentnl
Power Poster
Power Poster
Posts: 493
Joined: Mon May 11, 2009 4:35 pm

.htaccess on multiple domains included pretty url

Post 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..
User avatar
kermit
Power Poster
Power Poster
Posts: 693
Joined: Thu Jan 26, 2006 11:46 am

Re: .htaccess on multiple domains included pretty url

Post 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 /
Last edited by kermit on Sun Jun 13, 2010 11:34 am, edited 1 time in total.
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
Post Reply

Return to “General Discussion”