301 Redirects (and stripping out www/subdomains)

First of all, apologies in advance for such a n00b question.

I’ve just performed a fresh install of Radiant 0.6

My usual practice when setting up a site is to immediately strip www
from the URL (via mod rewrite and a 301 redirect), however my attempts
to modify the .htaccess file in Radiants ‘public’ folder have
accomplished nothing.

.htaccess is currently as it was immediately after install. My current
issue is that the following URL’s all serve the same page:

http://example.com
http://www.example.com
http://anythingelseyoucaretotry.example.com

Does anyone have any suggestions as to how I can accomplish my goal? I
don’t expect to be hand-held, but if there are resources that I’ve
overlooked I’d appreciate a shove in the right direction. (A trawl of
the web and assorted forums hasn’t produced any relevant info).

Thanks in advance.

P.S.

I’m using Media Temple. The following can be found immediately after
‘RewriteEngine On’.

#MTSTART – Automatically generated, don’t modify –
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ http://xx.x.xxx.xxx:2010/${escape:$1} [P]
#MTEND

My current issue is that the following URL’s all serve the same page:

http://example.com
http://www.example.com
http://anythingelseyoucaretotry.example.com

I’m using Media Temple.

Likewise, on both counts. (Although I feel this is a Rails/MT issue
rather than a Radiant one).

I’m not convinced editing the .htaccess file is even the way to go in
this situation; given the ‘automatically generated’ MT code is already
rewriting the URL through a proxy.

Please excuse my ignorance, I’m new to both RoR & Radiant, but a one
word yes/no answer from someone with knowledge of the platform would be
extremely helpful.

Anyone?

Hi Suzanne,

This is something that you could be handling quite easily in your web
server
rather than in your application. In Apache for example, adding the
following
right after the “RewriteEngine On” line would achieve what you want:

Redirect non-mydomain.co.uk domains

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^mydomain.co.uk
RewriteRule (.*) http://mydomain.co.uk/$1 [R=301,L]

After this you should have the default Rails/Radiant content and
everything
will get picked up correctly as the above code is only processed when
the
domain does not match your wanted domain and halts processing after the
redirect when it doesn’t.

Best Regards,
Kevin A.

Or you can use this if you are using lighttpd

from any www.host (with www.) to the host (without www.)

$HTTP[“host”] =~ “^www.(.)" {
url.redirect = ( "^/(.
)” => “http://%1/$1” )
}

another good place to look is
http://no-www.org/

Martin

right after the “RewriteEngine On” line would achieve what you want:

Redirect non-mydomain.co.uk domains

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^mydomain.co.uk
RewriteRule (.*) http://mydomain.co.uk/$1 [R=301,L]

After this you should have the default Rails/Radiant content and
everything
will get picked up correctly as the above code is only processed when
the
domain does not match your wanted domain and halts processing after the
redirect when it doesn’t.

Best Regards,
Kevin A.

Thanks for replying, Kevin.

Your example is virtually identical to how I normally re-write URL’s.
However, I may have misinterpreted what the original poster was
attempting, allow me to elaborate…

When a Rails app is installed on a MT grid server the html/public_html
folder is removed from that of the domain and replaced with a sym link
to the app. Which is why I thought the poster may have been trying to
place the re-write rule before the (quoted) ‘automatically generated’
Media Temple code. Because, obviously, dropping an .htaccess complete
with re-write rules into the domain folder wont do a thing.

Personally, I have a few other approaches to try before I resort to tech
support, but if anyone has suggestions, I’d welcome them.

Thanks, Suzanne.