Setup redirects with Modsec

apache-2.4mod-security

The web servers I managed are all running Apache 2.4 with Modsec. Is it possible to write a rule that will serve up a different page if matched by Modsec? I want this to be independent of the domain.

For example, if domain1.com/login or domain2.com/login redirect to domain3.com.

Best Answer

Yes you can, use the redirect action.

For example:

SecRule REQUEST_URI "/login" "phase:1,id:52,status:302,redirect:https://domain3.com

Though if doing a straight redirect like above you’d be better doing this in Apache.

Related Topic