lunes, 29 de agosto de 2011

301 redirection with wikidot pages

Visto en http://doc.wikidot.com/module:redirect

Redirect
Short Description
Performs a "301" redirect from a page with optional URL mapping

Description

The Redirect module performs a "301 Permanently Moved" redirection, i.e. it tells a web browser to request another web page.

Attributes

attribute required allowed values default description
destination yes page-name or URL none where to redirect?
When the destination attribute is just an alphanumeric string, e.g. "start", the page which contains the Redirect module will automatically forward the browser to the wiki page called "start". If destination is the whole URL address (e.g. "http://slashdot.org"), the browser will be redirected to this external address.

Mapping

If the destination attribute ends with a slash, e.g. destination="start/" or destination="http://www.example.com/", the current URL will be mapped to the destination in the following way. The code for the module would be:
[[module Redirect destination="http://www.example.com/base/"]]
Now if the Redirect module is placed on page http://your-wiki.wikidot.com/redir the following mapping will be performed:
from to
http://your-wiki.wikidot.com/redir http://www.example.com/base/
http://your-wiki.wikidot.com/redir/mapped-path http://www.example.com/base/mapped-path
http://your-wiki.wikidot.com/redir/mapped-path/file1.html http://www.example.com/base/mapped-path/file1.html

Preventing the redirect

If the Redirect module redirected the browser always there would be no way to edit the actual page. The solution is to pass an extra parameter to the module in the URL as follows:
http://your-wiki.wikidot.com/page-with-redirect/noredirect/true
There should be an information box where the module is placed.
Working with the Redirect module might not be very convenient but even of you have to do this you will not configure it every day ;-)



domingo, 28 de agosto de 2011

Use '=' or LIKE to compare strings in SQL?


LIKE and the equality operator have different purposes, they don't do the same thing: = is much faster, whereas LIKE can interpret wildcards. Use = wherever you can and LIKE wherever you must.

SELECT * FROM user WHERE login LIKE 'Test%';
-- Matches
-- TestUser1
-- TestUser2
-- TestU
-- Test
-- etc.

Registros duplicados con SQL

Here's a handy query for finding duplicates in a table. Suppose you want to find all email addresses in a table that exist more than once:

SELECT email,
COUNT(email) AS NumOccurrences
FROM users
GROUP BY email
HAVING ( COUNT(email) > 1 )

You could also use this technique to find rows that occur exactly once:
SELECT email
FROM users
GROUP BY email
HAVING ( COUNT(email) = 1 )

Limpiar un Wordpress hackeado

 Check list para limpiar instancias de Wordpress que han sido hackeadas, y para prevenir hackeos. Para técnicos de sistemas con acceso SSH a...