Understand and Enable Search Engine Friendly (SEF) in Joomla

Search Engine Friendly(SEF) also known as human readable URL. With the most famous Web Service like Nginx, Apache and IIS7, they do support URL rewrite or mod_rewrite to rewrite the human readable URL such as www.domain.com/about instead of www.domain.com/about.html.

With Joomla 1.5 and above, Joomla come with 3 option from your Global Configuration.
–  Search Engine Friendly URLs – With this option enabled, SEF will enable and your URL will look like, http://www.example.com/index.php/the-­news/1-­latest­-news/1­-welcome­-to­-joomla.
– Use Apache mod_rewrite/URL rewriting – With this option enabled, mod_rewrite will eliminate inde.php and your URL will look like, http://www.example.com/the-­news/1­-latest-­news/1-­welcome-­to­-joomla
– Add suffix to URLs – With this option enabled, your URL will added .html at the end of the URL and it will look like http://www.example.com/the-­news/1­-latest-­news/1-­welcome-­to­-joomla.html

Nginx
To enable SEF with Nginx, add the following line to your (vhost)nginx.conf file.

# Support Clean (aka Search Engine Friendly) URLs</tt>
        location / {
                try_files $uri $uri/ /index.php?q=$request_uri;
        }

Apache
To enable SEF with Apache server, you may easily rename the htaccess.txt to .htaccess file. This step is not necessary as you may get your .htaccess file generated if it is install in  own folder.

IIS 7
With IIS 7, you may choose to use GUI or directly add it from web.config file.

With GUI interface, you may add the following option from the URL rewrite option.

Pattern field: ^([^/]+)/?$
Ignore case ON
Action type: Rewrite
Rewrite URL: index.php/

 Otherwise, you may add the following line to your web.config file.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="Common Exploit Blocking" stopProcessing="true">
                    <match url="^(.*)$" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{QUERY_STRING}" pattern="mosConfig_[a-zA-Z_]{1,21}(=|\%3D)" />
                        <add input="{QUERY_STRING}" pattern="base64_encode.*\(.*\)" />
                        <add input="{QUERY_STRING}" pattern="(\&lt;|%3C).*script.*(\>|%3E)" />
                        <add input="{QUERY_STRING}" pattern="GLOBALS(=|\[|\%[0-9A-Z]{0,2})" />
                        <add input="{QUERY_STRING}" pattern="_REQUEST(=|\[|\%[0-9A-Z]{0,2})" />
                    </conditions>
                    <action type="Redirect" url="index.php" appendQueryString="false" redirectType="SeeOther" />
                </rule>
                <rule name="Joomla Search Rule" stopProcessing="true">
                    <match url="(.*)" ignoreCase="true" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{URL}" pattern="^/search.php" ignoreCase="true" />
                    </conditions>
                    <action type="Rewrite" url="/index.php?option=com_content&amp;view=article&amp;id=4" />
                </rule>
                <rule name="Joomla Main Rewrite Rule" stopProcessing="true">
                    <match url="(.*)" ignoreCase="true" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{URL}" pattern="(/[^.]*|\.(php|html?|feed|pdf|raw))$" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php/" />
                </rule>
            </rules>
        </rewrite>
        <caching>
            <profiles>
                <add extension=".php" policy="DisableCache" kernelCachePolicy="DisableCache" />
            </profiles>
        </caching>
    </system.webServer>
</configuration>

PHP Compilation Error

It is not my first time to install PHP to the Linux server, but I am always not remember the error and which packages should install to get away the error.

So I am sharing some error code with the packages needed as below.

Error: Configure: error: xml2-config not found. Please check your libxml2 installation.
Solution:

yum install libxml2-devel

Error: Checking for pkg-config… /usr/bin/pkg-config configure: error: Cannot find OpenSSL’s
Solution:

yum install openssl-devel

Error: Configure: error: Cannot find MySQL header files under /usr.
Note that the MySQL client library is not bundled anymore!
Solution:

yum install mysql-devel

Error: Checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!
Solution:

yum install unixODBC-devel

Error: Configure: error: Cannot find pspell
Solution:

yum install pspell-devel

Calculate PHP Load time

Have you ever load a page with your Broadband just like using a Dial Up connection? Sometimes, it is not because of the ISP connection problem but it’s just because the scripting that not fully optimized.

If you design PHP script, it’s good practice to benchmark your pages to see the if you could optimize the pages.

The following script let you understand how fast your script loaded.

Put the following script to the most top of your PHP script just after the php tag.

$m_time = explode(" ",microtime());
$m_time = $m_time[0] + $m_time[1];
$loadstart = $m_time;

Then place this script to the bottom of the script to calculate the time.

$m_time = explode(" ",microtime());
$m_time = $m_time[0] + $m_time[1];
$loadend = $m_time;
$loadtotal = ($loadend - $loadstart);
echo "<small><em>Generated page in ". round($loadtotal,3) ." seconds</em></small>";

How WordPress feeds working?

Recently Mick Genie concentrate to Feed (RSS) from all around the world and found out that it is useful for a Tech Savvy to understand and know the news around the world.

To avoid outdate from the line Mick Genie stand right now, FeedDemon become my good friend. However, we are not discussing this by today but Mick Genie will guide you how the WordPress feeds working.

WordPress do built-in some feeds with RDF, RSS 1.0, RSS 2.0, ATOM for mail blog and your comments. To understand for more, please refer to detail below,

Feeds format for permalink,
http://mickgenie.com/feed/ (RSS 2.0 format)
http://mickgenie.com/feed/rss2/ (RSS 2.0 format)
http://mickgenie.com/feed/rss/ (RSS 0.92 format)
http://mickgenie.com/feed/rdf/ (RDF/RSS 1.0 format)
http://mickgenie.com/feed/atom/ (Atom format)

Continue reading How WordPress feeds working?

All in one redirect scripting

HTML redirect:

For most of the webmaster, they will prefer 301 Redirect. With HTML redirect with HTML, I will suggest canonical type.

You may use the following script from the HTML with canonical redirection.

<link rel="canonical" href="http://www.mickgenie.com/" />

htaccess with mod_rewrite redirect:

If you are using Apache or Mod_Rewrite enabled Web services, htaccess with mod_rewrite redirect is very useful, you may use the following script to perform your redirection.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mickgenie.com
RewriteRule (.*) http://www.mickgenie.com/$1 [R=301,L]

ColdFusion Redirect:

Sample code for Cold Fusion.

<cfheader name="Location" value="http://www.mickgenie.com/">

PHP Redirect:

Sample code for PHP.

<?php
header("location:http://www.mickgenie.com");
exit;
?>

ASP Redirect:

Sample Code for ASP.

<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "http://www.mickgenie.com/"
%>

ASP.Net Redirect:

Sample Code for ASP.Net.

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.AddHeader("Location","http://www.mickgenie.com/");
}
</script>

Java Redirect:

Sample Code for Java.

<%
response.setHeader( "Location", "http://www.mickgenie.com/" );
response.setHeader( "Connection", "close" );
%>

Perl & CGI redirect:

Sample Code for Perl & CGI.

$q = new CGI;
print $q-› redirect(" http://www.mickgenie.com/ ");

Ruby & Ruby on Rails Redirect:

Sample code for Ruby & Ruby on Rails.

head :moved_permanently, :location =› "http://www.mickgenie.com/

How to check WordPress version from backend

Today, I will share how a bad guy(hacker) try to scan your WordPress version however I am not going to share how to do this. 🙂

With WordPress 2.8.x or earlier, WordPress version status were stored in a file named version.php in the wp-includes folder, some plugin such as WP Security Scan will try to hide the WordPress version number from scanning.

In order to get your WordPress version, you may do like the following command to grep the WordPress version.

[email protected] [~]# grep wp_version wp-includes/version.php
* @global string $wp_version
$wp_version = ‘2.8.6’;

PHP with MSSQL not working

Sometimes you might wonder why you are not able to connect from PHP script with your MSSQL database as you have enabled php_mssql.dll extension from your php.ini.

Below are the step to resolve this issue;

But before we given the solution, you might get the following error message, however the error might just unable to connect to the MSSQL database without any further detail.

Cause:
Assume you were using IIS6/7 with PHP 5.2.x(Microsoft Windows Server 2003/2008),  you might get such issue if you are install the PHP with source installation.

Error:

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: localhost:1433 in C:\Domains\wwwroot\php_mssql.php on line 5
Couldn’t connect to SQL Server on localhost:1433

Solution:
1. Download file ntwdblib.dll from URL of http://www.dlldll.com/ntwdblib.dll_download.html.
2. Go to the server hosted for your PHP script.
3. Go to PHP directory, assume you are using C:\Program Files\PHP5.2.x\, backup original ntwdblib.dll.
4. Replace the file as downloaded from Step 1.

Test again, and your problem should resolved.

You may refer to the URL as below for more information on the PHP_MSSQL connect page available from PHP.Net
http://my.php.net/function.mssql-connect