htaccess.module in Htaccess 8.2
Htaccess is a module which autogenerates a Drupal root htaccess
file based on your settings.
File
htaccess.module
View source
<?php
define('HTACCESS_TEMPLATE_PATH', drupal_get_path('module', 'htaccess') . '/includes/htaccess.txt');
function htaccess_help($path, $arg) {
$output = '';
switch ($path) {
case "admin/help#htaccess":
$output = '<p>' . t("Auto generate htaccess. ") . '</p>';
break;
}
return $output;
}
function htaccess_cron() {
$root_path = \Drupal::root();
$htaccess_filepath = $root_path . '/.htaccess';
$htaccess_current = file_get_contents($htaccess_filepath);
if ($htaccess_current) {
$htaccess_deployed = db_select('htaccess', 'h')
->fields('h')
->condition('deployed', 1, '=')
->execute()
->fetchAssoc();
if ($htaccess_deployed) {
$htaccess_deployed = $htaccess_deployed['htaccess'];
if ($htaccess_current === $htaccess_deployed) {
\Drupal::config('htaccess.settings')
->clear('htaccess_altered')
->save();
}
else {
drupal_set_message(t('The htaccess seems to be altered.'), 'warning');
\Drupal::configFactory()
->getEditable('htaccess.settings')
->set('htaccess_altered', true)
->save();
}
}
}
}
Functions
Constants
Name |
Description |
HTACCESS_TEMPLATE_PATH |
@file
Htaccess is a module which autogenerates a Drupal root htaccess
file based on your settings. |