2

I have a defined in routes.php a regex that redirects all queries but api to my index template:

return array(
   '<url:(?!api).*>' => ['template' => 'index']
);

I'm trying to exclude robots.txt as well as Google Analytics which is utm_source=analytics_test&utm_medium=referral I've tried the following but it's not quite right:

return array(
   '<url:^(?!api|robots|utm_source)(.*)$>' => ['template' => 'index']
);

1 Answer 1

4
+50

This will redirect all queries but urls containing: api or robots or utm_source strings

return array(
   '^(?!.*(api|robots|utm_source)).*$' => ['template' => 'index']
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.