Chris Fadu Uba
Chris Fadu Uba

Reputation: 133

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

I'm having a problem with a script. It doen't works with a htaccess file that is needed to work. Here's what the htaccess contains. I'm trying to install it on a wamp localhost. The code is:

#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 works:

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 every page show error 404. Is there a way to resolve this problem??

Upvotes: 10

Views: 22585

Answers (4)

Mike
Mike

Reputation: 11

This is one solution that solved the issue for me. Rewrite module was always enabled, used in IfModule rewrite_module, permissions were granted and .htaccess contents were fine, yet it still was 500 error trying to use 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's filesystem. You must
# explicitly permit access to web content directories in other 
# <Directory> blocks below.
#

    <Directory />
        AllowOverride none
        Require all denied
    </Directory>
`    

So one may want to use .htaccess with rewrite module in a specific directory. You would add a <directory> block for that directory. If one copies and pastes the directory block, you need to make sure the intent of the block you copy is correct for the directory you want to apply it to.

So for my intent this block, causes a 403 error, but does get rid of the 500 error.

<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 this is why the issue is commonly seen, but rarely solved in these threads. If I simply copied a different block, typed my own block, or had any understanding of what I was doing, this wouldn't have been an issue.

I can't say this solves everybody's issue, but I hate when people solve-and-run w/o enlightening the rest of us. So for those that did my mistake, this is the answer.

Upvotes: 1

ouzza
ouzza

Reputation: 41

Check that you have the the apache rewrite module loaded.

go to wamp_manager -> apache -> modules and look for rewrite_module in the list.

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

The rewite engine will not work without the required module loaded.

Upvotes: 2

Menno van der Krift
Menno van der Krift

Reputation: 303

I had the same problem. To un-comment the line, remove the # in front of the line LoadModule rewrite_module modules/mod_rewrite.so

Worked for me in Wamp.

Directory of the httpd.conf file: C:\wamp\bin\apache\apache2.4.9\conf

Upvotes: 1

Jon Lin
Jon Lin

Reputation: 143866

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

LoadModule rewrite_module modules/mod_rewrite.so

Upvotes: 19

Related Questions