fitxer .htaccess en codeigniter 3 i 4
Created at: 2023-05-15 08:34:15 | Updated at: 2024-04-26 09:22:51
Para dejar nuestro desarrollo con un toque más profesional, simplemente añadimos en la raíz de nuestro sitio un archivo llamado .htaccess con el siguiente contenido y problema resuelto.
CODEIGNITER 3
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php?/$0 [PT,L]
Además debemos modificar el archivo application/config/config.php reemplazando la línea que dice
$config['index_page'] = 'index.php';
Por esto otro:
$config['index_page'] = '';
Eso es todo, ahora las URLs de nuestra aplicación serán limpias sin ese index.php agregado en medio.
www.misitio.com/controller/metodo
CODEIGNITER 4
<IfModule mod_rewrite.c> # That was ONLY to protect you from 500 errors # if your server did not have mod_rewrite enabled RewriteEngine On # RewriteBase / # NOT needed unless you're using mod_alias to redirect RewriteCond %{REQUEST_URI} !/public RewriteRule ^(.*)$ public/$1 [L] # Direct all requests to /public folder </IfModule>
No valid image directory found or the category is not valid for the gallery.