Apache
HtaccessRedirects
.htaccess redirects
Class: Drutiny\Audit\Apache\HtaccessRedirects
Extends: Drutiny\Audit
Package: drutiny/drutiny
Policies
These are the policies that use this class:
| Name | Title |
|---|---|
| Apache:LimitHtacessRedirects | .htaccess redirects |
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| max_redirects | integer | The maximum number of redirects to allow. | 10 |
Tokens
| Name | Type | Description | Default |
|---|---|---|---|
| max_redirects | integer | The maximum number of redirects to allow. | 10 |
| total_redirects | integer | The number of redirects counted. | 10 |
Source
public function audit(Sandbox $sandbox) {
$patterns = array(
'RedirectPermanent',
'Redirect(Match)?.*?(301|permanent) *$',
'RewriteRule.*\[.*R=(301|permanent).*\] *$',
);
$regex = '^ *(' . implode('|', $patterns) . ')';
$command = "grep -Ei '${regex}' %docroot%/.htaccess | wc -l";
$total_redirects = (int) $sandbox->exec($command);
$sandbox->setParameter('total_redirects', $total_redirects);
return $total_redirects < $sandbox->getParameter('max_redirects', 10);
}