Author |
|
gijs
Joined: 27 Apr 2012 Posts: 189 Location: The Netherlands
|
Posted: Sun 03 Jan '16 15:08 Post subject: Redirect domain without vhost and .htaccess |
|
|
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
|
Posted: Mon 04 Jan '16 17:55 Post subject: |
|
|
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
|
Posted: Mon 04 Jan '16 17:59 Post subject: |
|
|
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
|
|
Back to top |
|
covener
Joined: 23 Nov 2008 Posts: 60
|
Posted: Sun 10 Jan '16 21:07 Post subject: |
|
|
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
|
Posted: Sun 10 Jan '16 21:10 Post subject: |
|
|
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 |
|