Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite - bulk redirection

         

muszek

6:39 pm on Jan 17, 2007 (gmt 0)

10+ Year Member


Hi.

I have two domains: example.com and example.pl. The latter is the important one that I use everywhere. What I want is to redirect all hits from example.com, www.example.com and example.pl to www.example.pl in a way that the rest of the url stays intact (so for example http:/[smilestopper]/example.com/somedir/somefile.html would redirect the browser to http:/[smilestopper]/example.com/somedir/somefile.html).

Things that are important to me:
* it's transparent to the user - if it was up to me, people would never use those less important domains.
* http_referer stays intact. If a user clicks a link to example.com/url.html from somesite.net/someurl.html, I want to have somesite.net/someurl.html visible to apache after the redirect (I'm writing referers to the database).
* Google has no problem with it (no PR loss or anything like that).

Currently, I have an 'example' file in /etc/apache2/sites-available (linked from sites-enabled, of course) that lists www.example.pl as ServerName and example.pl, example.com and www.example.com as ServerAlias(es).
I think I should create another file (say example-aliases) for aliases, point them to a different DocumentRoot and have a simple .htaccess file that would redirect every query to the exact address at www.example.pl.

What would this .htaccess look like? I tried creating a similar one a few months ago and I couldn't succeed (I'm not an expert on either regex or mod_rewrite...).

If that matters, I'm using Drupal 5 on Debian Sarge with Apache 2.

jdMorgan

7:42 pm on Jan 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This search [google.com] should give you a good start.

Jim