Obtener URLs para usuarios en Codeigniter

Codeigniter tiene una método para tratar con las URLs: http://dominio/controlador/metodo/param1/param2/… El problema viene cuando nuestra aplicación necesita URLs diferentes, como las de Twitter u otra red social, que son del tipo http://dominio/username.

Para ello primero se debe cambiar el archivo routes.php de la configuración:

//Excluir estos controladores cuando se generan las URLs
$route['(login|oauth|site|search)(.*)'] = '$1$2';  
//Las URLs de los usuarios
$route['[a-zA-Z0-9]+/(add|edit)'] = 'users/$1';
$route['[a-zA-Z0-9]+'] = 'users/profile';

Después habrá que modificar el .htaccess para usar APP_PATH:

RewriteEngine On
RewriteBase /
RewriteCond %{ENV:REDIRECT_APP_PATH} !^$
RewriteRule ^(.*)$ - [E=APP_PATH:%{ENV:REDIRECT_APP_PATH}]
RewriteCond %{ENV:APP_PATH} ^$
RewriteRule ^(.*)$ - [E=APP_PATH:/$1]
RewriteCond $1 !^(index\.php|img|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]

Y por último modificar el config.php para indicar que debe usar el APP_PATH:

$config['uri_protocol']    = "APP_PATH";
$config['enable_query_strings'] = TRUE;

Codeigniter Vanity URLs

Vía / PHPDeveloper.org

HTML5′s “email” and “url” Input Types

I’ve already covered some subtle HTML5 improvements like placeholder, prefetching, and web storage.  Today I want to introduce a few new INPUT element types:  email and url.  Let’s take a very basic look at these new INPUT types and discuss their advantages.The SyntaxThe syntax is as basic as a text input;  instead, you set the type to “email” or “ …

Post original

Xeround: MySQL Elastic, Always-on Storage Engine for the Cloud

Xeround is a new MySQL storage engine offered as Database-as-a-Service. What it promises sounds (a bit?) too good to be true (nb this list have been extracted from their site): seamless replacement of existing MySQL database high availability (including schema changes) automatic fault-detection and recovery full consistency with low latency elastic …

Post original

Adding Stroke to Web Text

Fonts on the web are essentially vector based graphics. That’s why you can display them at 12px or 120px and they remain crisp and relatively sharp-edged. Vector means that their shape is determined by points and mathematics to describe the shape, rather than actual pixel data. Because they are vector, it would make sense if we could do things that …

Post original

How did Google Instant become Faster with 5-7X More Results Pages?

We don’t have a lot of details on how Google pulled off their technically very impressive Google Instant release, but in Google Instant behind the scenes, they did share some interesting facts: Google was serving more than a billion searches per day. With Google Instant they served 5-7X more results pages than previously. Typical search results wer …

Post original