Project

General

Profile

Domain redirect (301)

Added by Frisco over 15 years ago

Hi,

I have two domains, but I wan't the second to redirect to the first.

How should I solve this with lighty?

Is there a special way, or should I do something like apaches redirect:

RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.domain\.de$ [NC]
RewriteRule (.*) http://www.domain.de/$1 [R=301,L]

I would need this with www and without, could anyone translate this to lighty syntax (wouldn't like to bread my live server /-)?

And how can I tell lighty to put the status 301 with it?

Cheers
Frisco


Replies (3)

RE: Domain redirect (301) - Added by Frisco over 15 years ago

I tried mod.redirect, but there's something wrong, maybe one could help me?

$HTTP["host"] =~ "(|\.)domain1\.com" {
url.redirect = (
"
/(.*)" => "http://%1domain2.de/$1"
)
url.redirect-code = 301
}

This doesn't redirect if I try http://www.domain1.com and gives 404 for every subpage.

Any clues?

Cheers
Frisco

RE: Domain redirect (301) - Added by Frisco over 15 years ago

Ok, it's more easy with mod.redirct enabled (had to uncomment it at the start of lighttpd.conf), but one problem remains:

It only works for URLs without the www prefix.

http://www.domain1.de results in a redirect to http://.domain2.de

What's wrong?

Cheers
Frisco

[solved?] RE: Domain redirect (301) - Added by Frisco over 15 years ago

He guys,

it seems to work with this expression:

$HTTP["host"] =~ "(^.*|\.)domain1\.com" {
url.redirect = (
"/(.*)" => "http://%1domain2.de/$1"
)
url.redirect-code = 301
}

Cheers
Frisco

    (1-3/3)