function htaccess_generate_default in Htaccess 7.2
4 calls to htaccess_generate_default()
- htaccess_install in ./
htaccess.install - Implements hook_install(). Store the Drupal default htaccess into database.
- htaccess_update_7202 in ./
htaccess.install - Update default htaccess content. Disallow composer.json and composer.lock from being indexed. https://www.drupal.org/node/2392153 Htacess profiles won't be updated since it's not a security issue. Re-generate your htacess profiles only if…
- htaccess_update_7203 in ./
htaccess.install - Update default htaccess content. Add a new option which allows core text files from Drupal from being viewed.
- htaccess_update_7204 in ./
htaccess.install - Fixed the issue where the protect text files option is not properly taken into account
File
- ./
htaccess.module, line 119 - Htaccess is a module which autogenerates a Drupal root htaccess file based on your settings.
Code
function htaccess_generate_default() {
$htaccess_template = file_get_contents(HTACCESS_TEMPLATE_PATH);
$with_www_default = "#RewriteCond %{HTTP_HOST} .\n";
$with_www_default .= "#RewriteCond %{HTTP_HOST} !^www\\. [NC]\n";
$with_www_default .= "#RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
$without_www_default = "#RewriteCond %{HTTP_HOST} ^www\\.(.+)\$ [NC]\n";
$without_www_default .= "#RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]\n";
$search = array(
"%%%rules_before%%%",
"%%%prevent_txt%%%",
"%%%symbolic_links%%%",
"%%%ssl_force_redirect%%%",
"%%%with_www%%%",
"%%%without_www%%%",
"%%%boost_rules%%%",
);
$replace = array(
"",
"",
"+FollowSymLinks",
"",
$with_www_default,
$without_www_default,
"",
);
$htaccess_update = str_replace($search, $replace, $htaccess_template);
db_update('htaccess')
->fields(array(
'htaccess' => $htaccess_update,
))
->execute();
}