Sunday, May 20, 2007

How to remove the mails from exim mail queue based on certain keywords ( cPanel specific )

How to remove the mails from exim mail queue based on certain keywords, especially in a cPanel. Below command will help in that and is for cPanel server. Matter of seconds for a seasoned admin, but posting so that I can copy and paste in future.

find /var/spool/exim/input -type f | xargs grep -l 'search_keywords' | xargs rm -frv

Wednesday, May 02, 2007

mod_rewrite and REQUEST_URI

Yesterday I did a forum move , a SMF forum. We had to move the forum URL from http://www.domain.com/forum to http://www.domain.com along with moving the servers, but still not losing the links spidered by Google. So things had to be achieved by mod_rewrite and the below rewrite rule helped.

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/forum/(.*)$ [NC]
RewriteRule ^forum/(.*)$ /$1 [R=301,L]

What this will do is redirect

http://www.domain.com/forum/index.php?PHPSESSID=0aj813j131434061699fb61eef295f
to
http://www.domain.com/index.php?PHPSESSID=0aj813j131434061699fb61eef295f

Praise the mod_rewrite authors !!!

Tuesday, May 01, 2007

Forcing the files to be downloaded

Many of us have had to face the issue of making an txt file or .php file downloaded instead of the webserver parsing it and the browser displaying it. A simple entry as below in .htaccess and sometimes in your virtualhost section of httpd.conf can get this done.


Header add Content-Disposition "Attachment"