logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Redirect domain without vhost and .htaccess
Author
gijs



Joined: 27 Apr 2012
Posts: 189
Location: The Netherlands

PostPosted: Sun 03 Jan '16 15:08    Post subject: Redirect domain without vhost and .htaccess Reply with quote

I'm wondering if it's possible to add a simple redirect from one domain to another .in Apache without the need for a vhost for the original domain.

e.g. domain.com > domain.net
But without the need for a virtualhost for domain.com and a .htaccess file.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7407
Location: EU, Germany, Next to Hamburg

PostPosted: Mon 04 Jan '16 17:55    Post subject: Reply with quote

If the old domain is on a different server then

Code:
Redirect 301 / http://www.other-domain.de


if it is the same vhost

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.new-domain\.de$ [NC]
RewriteRule ^(.*)$ https://www.new-domain.de/$1 [L,R=301]
Back to top
gijs



Joined: 27 Apr 2012
Posts: 189
Location: The Netherlands

PostPosted: Mon 04 Jan '16 17:59    Post subject: Reply with quote

They both are on the same server.

But by the looks if it I can just add a 301 redirect in my main config from the old domain to the new domain? Without the need for a vhost and .htaccess for the old domain? (so simply adding a redirect and forwarding the IP from the old domain to this server)
Back to top
gijs



Joined: 27 Apr 2012
Posts: 189
Location: The Netherlands

PostPosted: Sun 10 Jan '16 17:55    Post subject: Reply with quote

Why does this not work? (it's in my main apache2.conf, the old domain doesn't have a vhost)

RedirectMatch 301 http://www.olddomain.com/(.*)$ https://www.newdomain.net/$1
RedirectMatch 301 http://olddomain.com/(.*)$ https://www.newdomain.net/$1
Back to top
covener



Joined: 23 Nov 2008
Posts: 60

PostPosted: Sun 10 Jan '16 21:07    Post subject: Reply with quote

gijs wrote:
Why does this not work? (it's in my main apache2.conf, the old domain doesn't have a vhost)

RedirectMatch 301 http://www.olddomain.com/(.*)$ https://www.newdomain.net/$1
RedirectMatch 301 http://olddomain.com/(.*)$ https://www.newdomain.net/$1


Because redirectmatch matches against the path component of the URL. There's no scheme or host on what the first param is compared to.
Back to top
gijs



Joined: 27 Apr 2012
Posts: 189
Location: The Netherlands

PostPosted: Sun 10 Jan '16 21:10    Post subject: Reply with quote

So it's not possible to redirect without a virtualhost for this domain? I'm confused.

My question was how can I redirect a request from my old domain to a new domain by simply pointing the IP to the new server that hosts the new domain.

All I need is a redirect, no need for a htdocs folder and all that stuff that a normal domain needs.
Back to top


Reply to topic   Topic: Redirect domain without vhost and .htaccess View previous topic :: View next topic
Post new topic   Forum Index -> Apache