-1

I've very little knowledge in this area - hence the question... I'm looking to do the following:

I currently have a server with a number of websites listed in sites-available and sites-enabled. There is a large list of websites which are no longer in use and I currently have a htaccess in the root of the websites that direct traffic to a new domain like so:

#redirect www.olddomain.ie to www.newdomain.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^olddomain.ie [NC,OR]
RewriteCond %{HTTP_HOST} ^www.newdomain.ie [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301,NC]

Then in the www.newdomain.com website htaccess I have a load of 301 redirects which handle the legacy website pages which no longer exist.

My questions is however if I remove www.olddomain.ie from my sites-available and sites-enabled can I still achieve something similar to the above? Can the above be placed into the httpd.conf file?

Apologies if this is a basic question, like I said I don't have a lot of knowledge in this area.

Thanks and any help is much appreciated.

Javacadabra
  • 101
  • 6
  • Possible duplicate of [Redirect, Change URLs or Redirect HTTP to HTTPS in Apache - Everything You Ever Wanted to Know About Mod\_Rewrite Rules but Were Afraid to Ask](http://serverfault.com/questions/214512/redirect-change-urls-or-redirect-http-to-https-in-apache-everything-you-ever) – MadHatter Jun 20 '16 at 09:54
  • @MadHatter I don't know if this is necessarily a duplicate... I'm more concerned about whether I can do the above from the httpd.conf file as opposed to actually implementing the rewrite rules - I am familiar with flags and 301s etc. – Javacadabra Jun 20 '16 at 09:56
  • The duplicate is a [canonical](http://meta.serverfault.com/questions/1986/what-are-the-canonical-answers-weve-discovered-over-the-years) question; if the function of those isn't clear to you, the link above may help. But it's only my opinion that this is a dupe; nothing happens unless four other high-rep users agree with me, and even if they do, someone may provide an answer first. – MadHatter Jun 20 '16 at 09:59
  • Oh no I appreciate what your saying, and thanks for linking to the above its certainly helpful. :) – Javacadabra Jun 20 '16 at 10:01
  • 1
    No worries. Regardless of how it happens, I hope you get your problem sorted out. – MadHatter Jun 20 '16 at 10:01

1 Answers1

1

You will need to have an active vhost serving the domain you want to redirect, even if not in use. It will work absolutely fine in the httpd.conf file, Apache is set to read from all *.conf files.

user156235
  • 61
  • 1
  • 9