Remove index.php from WordPress Permalinks

14/10/2010 | 20:41 | Code

Sometimes it can happens when you install WordPress with the default permalink structure everything will work fine. But when you want to change the permalink to /%year%/%monthnum%/%postname%/ it creates the following url index.php/%year%/%monthnum%/%postname%/ (mind the index.php).

The reason of this problem is that WordPress doesn’t think it’s running on Apache so it doesn’t create/write to the .htaccess file. It looks at the $_SERVER['SERVER_SOFTWARE'] variable which comes back with “WebServerX” based on what phpinfo() says on your server.

So, if you edit the /wp-includes/vars.php file and change the server detection area to:

// Server detection
// $is_apache = ((strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) || (strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false)) ? true : false;
$is_apache = 1;
$is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false) ? true : false;

It should work. Basically just bypassing the variable check and manually telling it that it’s running on Apache will remove the index.php from the url.

Validate identical passwords with Zend Framework

9/10/2010 | 19:55 | Code, Zend

When creating some fancy user registration or login form you’ll likely need an easy way to compare the users chosen and confirmed passwords. Here’s a little example how this easily can be done with the Zend Framework validator Identical:

$password = new Zend_Form_Element_Password('password');
$password->setLabel('New Password:');
$password->setRequired(true);
 
$confirm = new Zend_Form_Element_Password('confirm');
$confirm->setLabel('Confirm New Password:');
$confirm->setRequired(true);
$confirm->addValidator('Identical', false, array('token' => 'password'));

More information can be found here.