httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Warwick" <mwarw...@stwgtn.co.nz>
Subject RE: Redirecting URLS...
Date Thu, 15 Aug 2002 21:00:21 GMT
First, I think that the convention of starting web addresses with 'www.'
is annoying. It is easier to say 'amazon dot com' than 'w w w dot amazon
dot com' or worse still 'dub dub dub amazon dot com' as some are
beginning to do. Our company as a policy dumps the 'www' and enforces
lowercase in the domain name, using an external redirect the correct
name for our website is displayed in the browser and in the
bookmarks/favourites.

The solution I use is mod rewrite which can run in .htaccess provided
you host has the module loaded. Try http://WWW.Argest.Co.NZ to see how
it works (It works for either .com or .co.nz suffixes).

The relevant lines are:

#s&t customisations:
#enforce lowercase domain name
RewriteMap lowercase int:tolower
RewriteCond %{HTTP_HOST}   .*[A-Z].*
RewriteRule ^(.*)          http://{lowercase:%{HTTP_HOST}}$1   [R] 

#strip www - permanent [R=301]
RewriteCond  %{HTTP_HOST}   ^www\..*$
RewriteRule  ^(.*)          %{HTTP_HOST}$1                     [C]
RewriteRule  ^www\.(.+)     http://$1                    [L,R=301]



Michael

-----Original Message-----
From: Matthijs Rohs [mailto:matthijs@rohs.nl]
Sent: Friday, 16 August 2002 1:32 a.m.
To: users@httpd.apache.org
Subject: FW: Redirecting URLS...




-----Oorspronkelijk bericht-----
Van: Matthijs Rohs [mailto:matthijs@rohs.nl] 
Verzonden: donderdag 15 augustus 2002 15:31
Aan: 'Boyle Owen'
Onderwerp: RE: Redirecting URLS...

Thnx :) one thing though:

When I put this in my .htaccess (mod_rewrite is loaded):

RewriteCond %{HTTP_HOST} ^home.rohs.nl$
RewriteCond %{REQUEST_URI} !^/home/
RewriteRule (.*) /home/$1

Then when someone loads http://home.rohs.nl/ that person will see what's
in http://rohs.nl/home/ so it is possible with .htaccess.

So I thought it was possible, with mod_rewrite for example, to do the
same with http://www.rohs.nl/ to http://rohs.nl/

Guess not according to you :)

ViVa

-----Oorspronkelijk bericht-----
Van: Boyle Owen [mailto:Owen.Boyle@swx.com] 
Verzonden: donderdag 15 augustus 2002 15:26
Aan: users@httpd.apache.org; matthijs@rohs.nl
Onderwerp: RE: Redirecting URLS...

>From: Matthijs Rohs [mailto:matthijs@rohs.nl]
>
>It's not on my own server, so I need to place it within .htaccess and
>not httpd.conf. What's the solution for that please?

I'm trying to figure out what you have here... Do you have a website
which is hosted by an ISP and you only have write access to your
document root (so can edit .htaccess files). But you cannot edit the
server config? Then the ISP has directed www.rohs.nl to your site but
you want other variants to go there too?
(If so, you could have said so to begin with...)

In any case, the simplest solution is to use the ServerAlias but you
cannot do that in .htaccess. This is not something you can do yourself -
you need your ISP to edit the server config as previously described. so
there is no "solution".

Think about it - if you could do what you want in .htaccess, you could
hijack anybody's site (just make www.amazon.com point to www.rohs.nl :-)

Rgds,

Owen Boyle



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message