
Activar módulo rewrite en Apache / Error «auth/login was not found on this server»
08/09/2009Al ejecutar una aplicación php en un Apache, puede suceder el siguiente error:
The requested URL /var/www/aplicacion1/mysite/public/index.php/auth/login was not found on this server.
Esto probablemente se deba a una directiva especificada en el archivo .htaccess, que solicita al servidor web un determinado comportamiento.
RewriteEngine on
RewriteCond %{REQUEST_URI} !/public/.*
RewriteCond %{REQUEST_URI} !/images/.*
RewriteCond %{REQUEST_URI} !/layout/.*
RewriteRule .* index.php
php_flag magic_quotes_gpc off
php_flag register_globals off
php_value max_execution_time 120
Generalmente el problema es debido a la ausencia del módulo rewrite en la configuración de Apache. Para ello es necesario realizar tres pasos:
1º) Activar el módulo rewrite en Apache2.
ubuntu@ubuntu:/$ sudo a2enmod rewrite
Enabling module rewrite.
Run '/etc/init.d/apache2 restart' to activate new configuration!
2º) Modificar la configuración de Apache para indicar a qué sites alojados debe aplicarse el módulo «rewrite», sustituyendo «AllowOverride none» por AllowOverride All«.
ubuntu@ubuntu:/$ sudo nano /etc/apache2/sites-enabled/000-default
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
(…)
Realizar este cambio por tanto en las entradas en las que se quiera aplicar el módulo rewrite, generalmente en todas.
3º) Reiniciar Apache
root@ubuntu:/etc/apache2/sites-enabled# /etc/init.d/apache2 restart
* Restarting web server htcacheclean ...not running
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[ OK ]
Y de esta manera se consigue activar y configurar el módulo mod_rewrite en Apache2.
Hola, te agradezco el post, me ha sido de gran ayuda 😉