500 internal error with RewriteEngine on .htaccess on localhost using wamp

I have a problem with a script. It does not work with the htaccess file, which is necessary for work. It contains htaccess. I am trying to install it on a local wamp host. The code:

#AddType x-mapp-php5 .php #AddHandler x-mapp-php5 .php RewriteEngine ON RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [PT,L] #RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA] Options All -Indexes 

If I remove this, it will work:

 RewriteEngine ON RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [PT,L] #RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA] 

But this way the script loads, but each page shows a 404 error. Is there a way to solve this problem?

+8
.htaccess
source share
4 answers

It looks like you don't have rewriting modules loaded. Find the httpd.conf file and make sure that this line (or something similar) is uncommented:

 LoadModule rewrite_module modules/mod_rewrite.so 
+16
source share

Make sure apache rewrite module is loaded.

go to wamp_manager -> apache -> modules and find the rewrite_module file in the list.

If it does not have a TICK, click it. Apache will bounce (stop, start). Try again.

The rewrite engine will not work without loading a loaded module.

+2
source share

I had the same problem. To not comment on a line, remove the # before the line. LoadModule module rewrite_module / mod_rewrite.so

Worked for me at Wamp.

File directory httpd.conf: C: \ wamp \ bin \ apache \ apache2.4.9 \ conf

+1
source share

This is one solution that solved the problem for me. The rewrite module was always on, used in IfModule rewrite_module, permissions were provided, and the contents of .htaccess was fine, but still there were 500 errors when trying to use the rewrite module.

 In httpd.conf by default: This is a source of a 500 error if you try to use rewrite in .htaccess in some sub directory. ` # Deny access to the entirety of your server filesystem. You must # explicitly permit access to web content directories in other # <Directory> blocks below. # <Directory /> AllowOverride none Require all denied </Directory> ` 

This way you can use .htaccess with the rewrite module in a specific directory. You would add a <directory> block for this directory. If you copy and paste a directory block, you need to make sure that the target of the block you copied is correct for the directory to which you want to apply it.

So, for my intention, this block causes error 403, but gets rid of error 500.

 <Directory "c:/Apache24/htdocs/store"> AllowOverride All Options None Require all granted </Directory> Changing to this solved the issue: <Directory "c:/Apache24/htdocs/store"> AllowOverride All Require all granted </Directory> 

I suppose that's why the problem is often encountered, but rarely solved in these threads. If I just copied another block, typed in my own block, or had any idea what I was doing, that would not be a problem.

I can’t say that it solves all problems, but I hate it when people solve and run without understanding the rest of us. So for those who made my mistake, this is the answer.

0
source share

All Articles