Configuración .htaccess Symfony y WordPress
Me ha pasado que inexplicablemente de un día para otro, se borran los archivos .htaccess en en servidor. Puede pasar en algunos servidores poco serios, no va a faltar la oportunidad de sufrirlos.
En fin, les dejo el contenido de los archivos .htaccess que deben tener para que funcionen correctamente las aplicaciones Symfony y WordPress que en mi caso dejaron de funcionar.
Symfony: Dentro de /web/
Options +FollowSymLinks +ExecCGI<IfModule mod_rewrite.c>RewriteEngine On# uncomment the following line, if you are having trouble# getting no_script_name to work#RewriteBase /symfony_blog/web# we skip all files with .something#RewriteCond %{REQUEST_URI} \..+$#RewriteCond %{REQUEST_URI} !\.html$#RewriteRule .* – [L]# we check if the .html version is here (caching)RewriteRule ^$ index.html [QSA]RewriteRule ^([^.]+)$ $1.html [QSA]RewriteCond %{REQUEST_FILENAME} !-f# no, so we redirect to our front web controllerRewriteRule ^(.*)$ index.php [QSA,L]</IfModule>Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c> RewriteEngine On
# uncomment the following line, if you are having trouble # getting no_script_name to work #RewriteBase /symfony_blog/web
# we skip all files with .something #RewriteCond %{REQUEST_URI} \..+$ #RewriteCond %{REQUEST_URI} !\.html$ #RewriteRule .* – [L]# we check if the .html version is here (caching) RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
WordPress: En el directorio raíz
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
Cambiar lo que esté en rojo por su correspondiente directorio.
Otro Ejemplo para utilizar URL Amigables con htaccess
RewriteEngine on
Options +FollowSymLinks
RewriteRule (.*)\.htm$ index.php?p=$1
