Skip to main content

Add www to URL using Apache mod_rewrite

Submitted by amitsedai on
For sites belonging to a domain name(Not Subdomain), one can access the site using the domain name with www, Ex: www.example.com or without it: example.com Both ways the site can be accessed when a ServerAlias is created in the config. However this is confusing as session information for both is different, which means if one is accessing the site with www preceded and logs in, on accessing the site without www preceded - the server would have no information saved. To redirect any domain name to use www by default, the following mod_rewrite condition can be used:

Executing Views Bulk Operations Using Drush

Submitted by amitsedai on
Many times we use Views Buk Operations with Batch Api for doing a big set of operations. When the count of operations is huge, even Batch API gets short. A faster and more efficient way to do that is using drush to do the heavy backlifting. The commands are:
vbo-execute Execute a bulk operation based on a Views Bulk Operations (VBO) view.
vbo-list List all Views Bulk Operations (VBO) views, along with the operations associated with each.

Examples:

SVN: Creating a Repository and Migration

Submitted by amitsedai on
Creating a Repository There are loads of documentation in creating a Repository. Provided below is an example VHOST config file for SVN: ServerName svn.example.com
DocumentRoot /home/svn/

DAV svn
SVNPath /home/svn/reponame
# SVNParentPath /var/svn/
AuthType Basic
AuthName "Example Repository"
AuthUserFile /etc/subversion/passwd
Require valid-user

ErrorLog /home/svn/logs/error.log
CustomLog /home/svn/logs/access.log combined

Handling Unwanted Stuff

Submitted by amitsedai on
This is not a post for handling SPAM. Please find the following Softwares you would need to install. 1. ModSecurity supplies an array of request filtering and other security features to the Apache HTTP Server, IIS and NGINX. ModSecurity is a web application layer firewall. 2. Mod_evasive prevents against ddos and scripted bots which can hammer a website. Mod_evasive is the Web Denial of Service module used in ASL. It is designed to throttle http and https connections when they reach above a specified threshold.

Disabling Munin and Awstats

Submitted by amitsedai on
Munin is a server and network monitoring tool. AWStats is a free powerful and featureful tool that generates advanced web, streaming, ftp or mail server statistics, graphically. This log analyzer works as a CGI or from command line and shows you all possible information your log contains, in few graphical web pages. Sometimes both can result in High Server i/o due to its periodic cron tasks. Uninstalling via command line wont help as you may see cron based tasks for Munin and Awstats running in logs.

User Profiles On Registrations - Per Role

Submitted by amitsedai on
Dear Dhongis, We have almost all sites where we have multiple roles and we need a different profile for each role. This was so far rocket science since we did not have a mechanism to create different looking registration forms per user role. We handled this situation post login when we asked people to create profiles as per their roles. Also, we have an issue of assigning roles when logically a person should be able to choose their role and admins should simple approve or disapprove of it. Walking by the PC One September Afternoon I found the solution But not very soon

How to send email from loclahost Drupal hosted in Ubuntu?

Submitted by sunildhimal on
Consider a situation in which you have installed Drupal in your Ubuntu machine. Now you would like to start sending email from localhost.If you have not setup Mail Transfer Agent(MTA) than you will not be able to send email from localhost. What is Mail Transfer Agent(MTA)? Wikipedia Says:

Utility Methods

Submitted by amitsedai on
function_exists: function_exists — Return TRUE if the given function has been defined Syntax:
bool function_exists ( string $function_name )
Example: <?php if (function_exists('payroll_getcomponents')) { echo("payroll_getcomponents functions is available"); }else{ echo("payroll_getcomponents functions is NOT available"); } ?> profile2_load_by_user: Loads the profile data of a user. Takes user id as input Syntax:
profile2_load_by_user($account, $type_name = NULL)
Example: <?php

How to Set Filters for a View in Drupal 7 programmatically

Submitted by amitsedai on
Accessing a view programmatically <?php $view = views_get_view('view_name'); $view->init(); $view->set_display('default'); // or display id like page_1, block_1 $view->set_arguments(array($ARGS)); //display_name = 'default' or 'page' and so on //filter_name is the name of the filter //debug($view->display['display_name']->handler->options['filters']['filter_name']); $view->display['default']->handler->options['filters']['date_filter']['value']['min']='2012-05-01'; $view->display['default']->handler->options['filters']['date_filter']['value']['max']='2012-06-30';