Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mod_rewrite "400 Bad Request" problem

Tags:

mod-rewrite

I can't seem to get past a Bad Request error while setting up mod_rewrite. I've been trying for a while, so here's what I have.

The url I'm trying to access is:

gordons.local/brewCalc

The page I'd like to see is

gordons.local/index.php?page=brewCalc

Here's my rewrite rule:

    RewriteEngine on
    RewriteLog /var/www/gordons.com/logs/rewrite.log
    RewriteRule ([^/]+)/?$ index.php?page=$1 [L]

I've used a regex tool, and this tool, but no matter what I end up with a page that says:

Bad Request

Your browser sent a request that this server could not understand.
Additionally, a 400 Bad Request error was encountered while trying to use an ErrorDocument to handle the request.

Apache/2.2.12 (Ubuntu) Server at gordons.local Port 80

Also, I'm not getting any information in my access, error or rewrite logs.

EDIT: My rewrite rules are in my vhost file. (/etc/apache2/sites-available/gordons.local)

like image 404
Parris Varney Avatar asked May 24 '11 02:05

Parris Varney


1 Answers

In case anybody ever finds themselves here, my issue was a missing leading slash before the replacement.

RewriteRule ([^/]+)/?$ index.php?page=$1 [L]

Should have been

RewriteRule ([^/]+)/?$ /index.php?page=$1 [L]

Grrrr....

like image 118
Parris Varney Avatar answered Sep 25 '22 23:09

Parris Varney