Sufi Nawaz

I build stuff

SELinux settings to allow apache to send mail

Posted by in Code Snippets, Tutorials

I was working in a WordPress instance today that is installed in a Centos box. The issue was that I could not send any email through wp_mail() function in wordpress, which essentially uses PHP’s mail() function, which in turn, uses sendmail. So the very first thing I’ve tried doing was to create a simple PHP test script and ran it from the machine locally. The email worked fine so I knew sendmail was not the problem. Next, I tried to execute the script over the webserver, and sure enough, the…read more

Forwarding from non-www to www domain using URL rewrite rules in Apache

Posted by in Code Snippets, Technology

Problem Description: With the installation of WordPress multisite network in my site, entering the URL http://sufinawaz.com took me to the signup page whereas entering http://www.sufinawaz.com took me to the homepage as it should! I wanted http://sufinawaz.com to redirect to http://www.sufinawaz.com and http://sufinawaz.com/blog to http://www.sufinawaz.com/blog. Solution: I put the following block of codes right under the rule RewriteEngine On in .htaccess file and everything is a smooth sailing here onwards! RewriteCond %{HTTP_HOST} ^sufinawaz.com [NC] RewriteRule ^(.*)$ http://www.sufinawaz.com/$1 [L,R=301] PS: 301 is a search engine friendly HTTP redirect.  

0

How to parse RSS Feed XML from Blogspot using PHP

Posted by in Code Snippets, Technology

Mighty PHP allows us to do just about anything our hearts desire. Copy and paste the following code to your web page, and you’ll be parsing blog posts from blogspot in no time. The nifty little simplexml_load_file function used here allows you to parse XML files with a level of ease comparable to picking teeth with a toothpick. This function alone opened up a new horizon of creativity for me. I hope you guys find this useful and come up with your own creative ways of exploiting this function for…read more

0

Oh stop it Robots! Pretty please?

Posted by in Code Snippets, Technology

So most of us who have a website, usually want the contents to be searchable over the world wide web – I mean that’s the whole point for putting up a website in the first place, right? While we are so eager about our contents getting more hits, there are rare cases however, when we actually do feel a bit shy about the popularity of our pages over search engines like Google. It is then and only then do we look for ways to tell the web robots to stay…read more

0