Cybercampbell Cybercampbell - 8 months ago 29
PHP Question

Best way to manage redirects

I need to have a temporary redirect setup and I just want to know the best way to go. I've looked into .htaccess, php, meta and contributed Drupal modules (this is with a Drupal 8 site) and I don't know which is the way to go.

It is a little complicated and yes I know, not ideal but I need this setup for the next 3 months while I build my new website. I'm just not ready for that to switch over just yet.

This is what I need to do: -> -> ->

In other words, anything to the main domain only (no sub directory) gets bumped back to the old site URL.

But my subpages (micro-sites) go through as normal on the new site.

This is what I have so far using .htaccess:

RewriteCond %{HTTP_HOST} ^(www\.)?myNewDomain\.com [NC]
RewriteRule ^/?$ [L,R=301]

Any advise is very much appreciated.


You don't actually need mod_rewrite to do this.

You want a simple redirect just for a URI of / with nothing following it; everything else isn't redirected.

Try this (I haven't):

RedirectMatch ^/$