leungeric.com

Digg del.icio.us Technorati StumbleUpon Twitter

Force www. in your URL using .htaccess

.htaccess | Tutorials & Resources

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Just add the following code to your .htaccess file in the highest folder of your web directory and yor visitors will be forced to use the www version.

RewriteEngine on

RewriteCond %{HTTP_HOST} !^www.your_domain.com$

RewriteRule ^(.*)$ http://www.your_domain.com/$1 [R=301]

Get Remote Webpage Information

Code Snippets | PHP | PHP | Tutorials & Resources

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Simple code snippet to retrieve remote webpage information, including page title, page description, and keywords

<?php
$url = “http://www.leungeric.com/”;
$fp = fopen( $url, ‘r’ );
$content = “”;
while( !feof( $fp ) ) {
$buffer = trim( fgets( $fp, 4096 ) );
$content .= $buffer;
}

$start = ‘<title>’;
$end = ‘<\/title>’;

preg_match( “/$start(.*)$end/s”, $content, $match );
$title = $match[ 1 ];

$metatagarray = get_meta_tags( $url );
$keywords = $metatagarray[ "keywords" ];
$description = $metatagarray[ "description" ];

echo “<div>URL: $url</div>\n”;
echo “<div>Title: $title</div>\n”;
echo “<div>Description: $description</div>\n”;
echo “<div>Keywords: $keywords</div>\n”;
?>

Turning MySQL Data to UTF-8

MySQL | PHP | Tutorials & Resources

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Just add below line after MySQL connection is establisted:

mysql_query(”SET NAMES utf8″);

Import / Restore Large MySQL Data File

MySQL | Tutorials & Resources

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

A simple 3-steps procedure to import/restore large MySQL data file via command line.

A 200mb data file should take less than a minute to complete.

1. Telnet or SSH to server

2. Login to MySQL

mysql -u user -ppassword

3. At MySQL prompt

use your_database_name

source your_sql_data_file.sql

WordPress Plugin - Clicky Statistics

Tutorials & Resources | WordPress

1 Star2 Stars3 Stars4 Stars5 Stars (5 out of 5)
Loading ... Loading ...

This plug-in retrieves Clicky statistics of your website via Clicky API 2.0 with cache supported.

You may define:

  1. Types of statistics to be displayed
  2. Statistics date range
  3. The maximum number of results that will be returned
  4. Cache timeout duration
  5. Multiple string replacements

Before using this plugin, you need to register a Clicky account, and setup Clicky WordPress Plugin.

(Read more)

wp_list_cats() children=0 Issue

Tutorials & Resources | WordPress

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

While you are customizing/developing your WordPress theme, if you found children=0 paramter is not working with wp_list_cats() function (deprecated), you should use wp_list_categories() function instead.

It’s important to note their parameters are different, comparison as below:

(Read more)

Feedburner Count As Plain Text

Code Snippets | PHP | Tutorials & Resources | WordPress

1 Star2 Stars3 Stars4 Stars5 Stars (5 out of 5)
Loading ... Loading ...

Make a call to the Feedburner API requesting the feedcount for a given burned feed.

(Read more)

.htaccess Cheat Sheet

.htaccess | Tutorials & Resources

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

.htaccess (Hypertext Access) is the default name of Apache’s directory-level configuration file. It provides the ability to customize configuration directives defined in the main configuration file. The configuration directives need to be in .htaccess context and the user needs appropriate permissions.

(Read more)

Recommended WordPress Plugins

Tutorials & Resources | WordPress

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Here is a list of recommended WordPress plugins, which are also being used on this site.

(Read more)

WordPress Image Upload HTTP Error Fix

.htaccess | Tutorials & Resources | WordPress

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

If your WordPress 2.5 installation shows an HTTP Error when uploading files using the media uploader, this is due to mod_security on the async-upload.php file which handles file uploads.

Just add a few lines to WordPress’ .htaccess file should fix that problem.

(Read more)

12»

Sponsors