Redirect for document root but not child folders

Using a single web hosting account to host multiple sites

Postby richardk » Tue Dec 16, 2008 6:44 am

Doh. From now on (in this thread) if i post code with
Code: Select all
Options +FollowSymLinks

it is a mistake so please remove it.

Do you have PHP? If you do, create a PHP file (/phpinfo.php) and put
Code: Select all
<?php phpinfo();

in it. Then go to myusername.myhost.co.uk/phpinfo.php and look for any variable containing myusername.myhost.co.uk.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby paulcobb » Tue Dec 16, 2008 8:34 am

Sorry PHP not enabled on this server.

I have had some feedback from my host in the meantime:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/<foldername>/.*
RewriteRule .* http://www.mywesite.co.uk/ [R=301,L]

The above code is what they tell me to use.
The rewrite rule works fine on it's own.
When I add the RewriteCond FF reports a rewrite loop!
paulcobb
 
Posts: 9
Joined: Mon Dec 15, 2008 8:43 am

Postby richardk » Tue Dec 16, 2008 8:57 am

Do you have any server-side languages available?

If not, ask your host what environmental variables are available that contain the domain name (from the address bar).
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby paulcobb » Tue Dec 16, 2008 9:30 am

I've requested the info
paulcobb
 
Posts: 9
Joined: Mon Dec 15, 2008 8:43 am

Postby paulcobb » Wed Dec 17, 2008 8:20 am

After some fiddling experimenting I have a solution that seems to work.
Would just like some comments please:

CODE
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/folder1/
RewriteCond %{REQUEST_URI} !^/folder2/
RewriteCond %{REQUEST_URI} !^/folder3/
RewriteCond %{REQUEST_URI} !^/folder4/
RewriteCond %{REQUEST_URI} !^/folder5/
RewriteCond %{REQUEST_URI} !^/folder6/
RewriteCond %{HTTP_HOST} !\.domain2\.org\.uk
RewriteCond %{HTTP_HOST} !\.domain3\.co\.uk
RewriteCond %{HTTP_HOST} !\.domain4\.co\.uk
RewriteCond %{HTTP_HOST} !\.domain5\.co\.uk
RewriteCond %{HTTP_HOST} !\.domain6\.co\.uk
RewriteRule (.*) http://www.mynewdomain.co.uk/ [R=301,L]

The document root contains folders 1 to 6 under which contain the site data for domains 2 to 6.
Folder 2 is domain 2 etc.
The URLs point directly to these folders.
The URL for username.hostname.co.uk points to the document root, which in turn now points to mynewdomain

The domain mynewdomain is actually domain4 on the same server.

The question is, the permanant redirect to mynewdomain is what I want for the username.hostname domain but are there any implications in terms of Search Engines and Google Analytics for the other domains ?
paulcobb
 
Posts: 9
Joined: Mon Dec 15, 2008 8:43 am

Postby richardk » Wed Dec 17, 2008 8:53 am

The question is, the permanant redirect to mynewdomain is what I want for the username.hostname domain but are there any implications in terms of Search Engines and Google Analytics for the other domains ?

If no redirect happens everything should be fine.

Don't you want the new URL path passed one to the mynewdomain.co.uk?
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/(folder1|folder2|folder3|folder4|folder5|folder6)(/.*)?$ [NC]
RewriteCond %{HTTP_HOST} !^(.*\.)?domain2\.org\.uk$ [NC]
RewriteCond %{HTTP_HOST} !^(.*\.)?(domain3|domain4|domain5|domain6)\.co\.uk$ [NC]
RewriteRule ^(.*)$ http://www.mynewdomain.co.uk/$1 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Previous

Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 16 guests

cron