«La configuración del archivo .htaccess de Apache (hypertext access) puede ser una herramienta muy ponderosa en el desarrollo web si se utiliza de la forma adecuada. Mediante .htaccess podremos realizar redirecciones, proteger archivos y directorios con contraseña, prevenir el hotlinking y el robo de ancho de banda, comprimir archivos y mucho, mucho más. Entérate cómo«.
http://www.elwebmaster.com/articulos/21-hacks-de-htaccess-que-todo-desarrollador-deberia-conocer
Best .htaccess Hacks For Websites
Tips y hacks para el archivo de configuración del servidor apache, .htaccess. «The .htaccess configuration file on your server which controls Apache Server is an important file and a very powerful tool for your website if used properly. It is generally found in root of your web server. In this article I will share how .htaccess can help improve your website’s stability, security, functionality and usability.»
https://priteshgupta.com/2011/05/best-htaccess-hacks-website/
Proteger WordPress con el archivo htaccess
Artículo de la web active24.es sobre Cómo proteger WordPress sin complementos, simplemente usando el archivo .htaccess.
https://www.active24.es/como-crear-una-web/wordpress/proteger-wordpress-htaccess
Redirigir páginas de idiomas en Prestashop con .htaccess
Un post recuperado de KnowHow
Para redirigir una URL de Prestashop de un idioma a otro podemos lograrlo de forma muy sencilla y rápida con el archivo .htaccess, el archivo de configuración del servidor Apache.
#Redirigimos la página del idioma inglés (/en) de nuestra tienda online a la página española (/es)
Redirect 301 /en http://www.midominio.com/es
Redirect 301 /en http://www.midominio.com/es
Redirect 301 /fr http://www.midominio.com/es
OJO! Recordemos siempres hacer una copia del archivo .htacces original.
La página que queremos redirigir no debe escribirse con la dirección completa, es decir http://www.midominio.com/en se escribiría solo /en. A la dirección que queremos redirigirla si que tiene que escribirse con la URI completa: http://www.midominio.com/es
# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
# http://www.prestashop.com – http://www.prestashop.com/forums
# GBP REDIRIJO IDIOMAS A LA VERSIÓN ESPAÑOLA
Redirect 301 /en http://www.midominio.com/es
Redirect 301 /fr http://www.midominio.com/es
SetEnv HTTP_MOD_REWRITE On
RewriteEngine on
#Domain: midominio.com
RewriteRule . – [E=REWRITEBASE:/]
RewriteRule ^api$ api/ [L]
RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]
# Images
RewriteRule ^([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L]
RewriteRule ^([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L]
RewriteRule ^c/([0-9]+)(-[.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L]
RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L]
# AlphaImageLoader for IE and fancybox
RewriteRule ^images_ie/?([^/]+).(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]
# Dispatcher
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ – [NC,L]
RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]
AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/x-font-woff .woff
Header add Access-Control-Allow-Origin «*»
#If rewrite mod isn’t enabled
ErrorDocument 404 /index.php?controller=404
# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
AddHandler x-mapp-php5.5 .php
Redirigir http a https con .htaccess
Redirigir páginas de Error 404 en PrestaShop a la Home
https://www.hnevado.es/blog/redireccionar-errores-404-a-la-home-en-prestashop/
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class PageNotFoundControllerCore extends FrontController
{
public $php_self = 'pagenotfound';
public $page_name = 'pagenotfound';
public $ssl = true;/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
/** AÑADO TEMA REDIRECCION ERRORES
*/
{
Tools::redirect();
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found');
if (preg_match('/.(gif|jpe?g|png|ico)$/i', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) {
$this->context->cookie->disallowWriting();
if (!isset($_SERVER['REDIRECT_URL'])) {
$_SERVER['REDIRECT_URL'] = '';
if (preg_match('@^'.__PS_BASE_URI__.'([0-9]+)-([_a-zA-Z0-9-]+)(/[_a-zA-Z0-9-]+)?.jpg$@', $_SERVER['REQUEST_URI'], $matches)) {
$_SERVER['REDIRECT_URL'] = __PS_BASE_URI__.'p/'.Image::getImgFolderStatic($matches[0]).'/'.$matches[0].'-'.$matches[1].'.jpg';
}
}
if (preg_match('#/p[0-9/]*/([0-9]+)-([_a-zA-Z]*).(png|jpe?g|gif)$#', $_SERVER['REDIRECT_URL'], $matches)) {
// Backward compatibility since we suffixed the template image with _default
if (Tools::strtolower(substr($matches[2], -8)) != '_default') {
header('Location: '.$this->context->link->getImageLink('', $matches[1], $matches[2]), true, 302);
exit;
} else {
$image_type = ImageType::getByNameNType($matches[2], 'products');
if ($image_type && count($image_type)) {
$root = _PS_PROD_IMG_DIR_;
$folder = Image::getImgFolderStatic($matches[1]);
$file = $matches[1];
$ext = '.'.$matches[3];
if (file_exists($root.$folder.$file.$ext)) {
if (ImageManager::resize($root.$folder.$file.$ext, $root.$folder.$file.'-'.$matches[2].$ext, (int)$image_type['width'], (int)$image_type['height'])) {
header('HTTP/1.1 200 Found');
header('Status: 200 Found');
header('Content-Type: image/jpg');
readfile($root.$folder.$file.'-'.$matches[2].$ext);
exit;
}
}
}
}
} elseif (preg_match('#/c/([0-9]+)-([_a-zA-Z]*).(png|jpe?g|gif)$#', $_SERVER['REDIRECT_URL'], $matches)) {
$image_type = ImageType::getByNameNType($matches[2], 'categories');
if ($image_type && count($image_type)) {
$root = _PS_CAT_IMG_DIR_;
$file = $matches[1];
$ext = '.'.$matches[3];
if (file_exists($root.$file.$ext)) {
if (ImageManager::resize($root.$file.$ext, $root.$file.'-'.$matches[2].$ext, (int)$image_type['width'],
(int)$image_type['height'])) {
header('HTTP/1.1 200 Found');
header('Status: 200 Found');
header('Content-Type: image/jpg');
readfile($root.$file.'-'.$matches[2].$ext);
exit;
}
}
}
}
header('Content-Type: image/gif');
readfile(_PS_IMG_DIR_.'404.gif');
exit;
} elseif (in_array(Tools::strtolower(substr($_SERVER['REQUEST_URI'], -3)), array('.js', 'css'))) {
$this->context->cookie->disallowWriting();
exit;
}
parent::initContent();
$this->setTemplate(_PS_THEME_DIR_.'404.tpl');
}
protected function canonicalRedirection($canonical_url = '')
{
// 404 - no need to redirect to the canonical url
}
protected function sslRedirection()
{
// 404 - no need to redirect
}
}