Skip to content

Instantly share code, notes, and snippets.

View m4TT3rs's full-sized avatar

Mattias Bohez m4TT3rs

  • Walking Men
  • Brussels
View GitHub Profile
@m4TT3rs
m4TT3rs / .htaccess
Created November 14, 2017 08:42
Some common .htaccess rules to use
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
# redirect to non www domain to www
RewriteCond %{HTTP_HOST} !\.acquia-sites\.com [NC] # exclude Acquia default domains
RewriteCond %{HTTP_HOST} !\.walkingmen\.com [NC] # exclude Walkingmen test domains
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{ENV:AH_SITE_ENVIRONMENT} prod
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@m4TT3rs
m4TT3rs / searched.md
Last active October 7, 2016 09:34
Search regexes

Regex search snippets

Search all drupal t(); functions in page.

t\(['"]([\w\s%])+['"]
@m4TT3rs
m4TT3rs / all text fields.php
Created October 7, 2016 07:44
Drupal7: If you use 'Localize' option for taxonomy translation mode, it is possible to add taxonomy custom fields to string translation (http://drupal.stackexchange.com/questions/141892/how-to-translate-custom-fields-in-taxonomy-terms)
<?php
function mymodule_i18n_string_list_taxonomy_alter(&$strings, $type, $object) {
if ($type == 'taxonomy_term' && $object) {
// Retrieve vocabulary and potential field instances
// for this vocabulary.
$vid = $object->vid;
$vocabulary = taxonomy_vocabulary_load($vid);
$field_instances = field_info_instances($type, $vocabulary->machine_name);
@m4TT3rs
m4TT3rs / gist:8912864
Created February 10, 2014 09:27
Mura cms 6.1 hack to enable utf-8 urls
<!--
run this bit once to change the database structure
We use mssql server and it does not support indexes on fields that are longer than 900bytes,
to allow a decent length of encoded urls we need more so the index had to be removed.
As we don't have ma ny pages in this site this did not have a performance inpact,
on larger sites this might not be a good idea.
-->
<cfscript>
$.getBean('dbUtility')
.setTable("tcontent")
@m4TT3rs
m4TT3rs / web.config
Last active August 29, 2015 13:56
Mura IIS 7 config to redirect utf-8 chars
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<!--
This setting enabled the use of the escaped character in the url,
IIs however still tries to decode them using the windows charset
-->
<security>
<requestFiltering allowDoubleEscaping="true" allowHighBitCharacters="true" />
</security>