Showing posts from October, 2021

Git initialise new repository with existing source

If you have an existing folder with code you want to push (commit) into a new fresh git repository you need to first create the repository in GitHub or Bitbucket. You also need to have git installed on your local machine. To start off in the directory you have your existing code project git init Connect to a remote repository git remote add origin Add files to the commit git add . Set the commit message git commit -m 'Initialise repo' Push files to the repo git push origin master Now the codebase is pushed into master branch in the git repo. Photo credit:  @synkevych

Using Apache Mod Rewrite to redirect from HTTP to HTTPS and from a different TLD

If there is a single domain and you want to remove www and force https so the final domain will be in the format: In .htaccess: RewriteCond %{HTTPS} off RewriteRule ^(.*)${REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^{REQUEST_URI} [L,R=301]   If the domain has a secondary top level domain such as, you will need to ensure that secondary domain has a valid ssl cert if you want to redirect from that. Use the following rules to also handle redirects from a second TLD to the main TLD: RewriteCond %{HTTP_HOST} ^ RewriteRule ^(.*)$$1 [L,R=301] RewriteCond %{HTTPS} off RewriteRule ^(.*)${REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^{REQUEST_URI} [L,R=301]   You will need to test all  the rules with the following urls which iterates through all permutations  (The following include some Drupal s