.htaccess 301 redirects breaking clean URLs I am trying to make a couple of (I think) very basic rewrite condition / rules in .htaccess.

I placed them as the first rule after RewriteEngine on. Things seemed fine locally, and the rules appeared to work in .htaccess tester under each scenario.

However, when I pushed the code live, clean urls stopped working. Everything was only accessible as its route, i.e. /node/1234 instead of /foo/page.

Here are the rules I added:

&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine on

  # Custom redirects
  RewriteRule ^ptistore/control/interviews(.*) http%{ENV:protossl}://%{HTTP_HOST}/nurse-interviews [NC,L,R=301]
  RewriteRule ^ptistore/control/news(.*) http%{ENV:protossl}://%{HTTP_HOST}/cpn-numbers [NC,L,R=301]


So, any hit on either URL should 301 to the provided URL. I tested them locally and they appeared to work (and not break clean URLs), but when I pushed it up to our Acquia environments, URLs were no longer rewritten.

I wound up implementing a RouteSubscriber to get around this for the moment:

/**
 * Class RedirectSubscriber
 * @package Drupal\mymodule_redirects\EventSubscriber
 */
class RedirectSubscriber implements EventSubscriberInterface {

  public function redirectIndexPHP(GetResponseEvent $event) {
    $request = $event-&gt;getRequest();
    $uri = $request-&gt;getRequestUri();

    if (preg_match('/ptistore\/control\/interviews\/.*/i', $uri)) {
      $response = new TrustedRedirectResponse('/nurse-interviews', 301);
      $event-&gt;setResponse($response);
    }

    if (preg_match('/ptistore\/control\/news\/.*/i', $uri)) {
      $response = new TrustedRedirectResponse('/news', 301);
      $event-&gt;setResponse($response);
    }
  }

  static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = array('redirectIndexPHP', 39);
    return $events;
  }
}


Which works... but I really would rather it live in .htaccess.

Did I just place my rules too early in the file? How can I correct this?
No idea how acquia hosting works, but I doubt they respect your .htaccess and possibly don't even use Apache.

Maybe they have their own configuration settings for that, I know that platform.sh (which uses nginx) does.

If not, then you don't really have a choice but to do it in Drupal.

You could also try the latest redirect release which has a new submodule that supports domain and wildcard based redirects.