.htaccess does not work on Linux (Debian) Apache2

I am using apache2 (my dummy server) which is already installed with my Debian . Everything is going well, but now the problem is with my .htaccess

 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] 

He does not work
I think because of the version of apache2 that I am using, and maybe because of problems with my code or something that I have on config on my server

I want to redirect my url to the index main page if its entry is incorrect or unavailable

+6
debian apache .htaccess mod-rewrite
Apr 01 '14 at 22:12
source share
3 answers

After spending the whole day, I got my answer

In the folder
apache2 -> available sites -> There is a file with a default name

By default we have to change it

From:

 <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> 

TO:

 <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> 

Works. He allowed the use of .htaccess files.

+25
Apr 02 '14 at 18:06
source share

I would like to add that /etc/apache2/mods-available/rewrite.load needs to be enabled:

 a2enmod rewrite 

In Debian, I thought it was turned on by default, but mine was not.

+7
Jun 16 '14 at 0:02
source share

This code:

 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ /index.php?url=$1 [QSA,R] 

redirects http://example.com/test.php to http://example.com/index.php?url=test.php if the file does not exist. The only difference between my code here and yours is that I have [R] instead of [QSA, L]. If it still does not work for you, and you have the htaccess file in the root folder, I don't think this is a problem with the htaccess file

+1
Apr 01 '14 at 23:21
source share



All Articles