I have a PHP application that loads for all URLs except the home page.

Visiting "https://my.site.com/" produces a "Bad Request" error message. Any other URL, for example, "https://my.site.com/SomePage/" works just fine. It's only the home page that does not work.

All pages use mod_rewrite and get routed through a single dispatch script, Director.php. Accessing Director.php directly also produces the "Bad Request" error.

BUT- ALL of the other requests go through Director, and they all work just fine, (excluding the home page), so it can't be an issue with the Director.php script? OR can it?

I'm not seeing anything in the Apache2 error log, and I'm not seeing any PHP errors in the PHP Error log. I've tried changing the first line of Director.php to read:

echo 'test';

But I still get a "Bad Request".

This is the rewrite log for a request to the home page: - - [18/Feb/2011:05:38:49 +0000] [my.site.com/sid#7f273d77cb80][rid#7f273da48b28/initial] (2) init rewrite engine with requested uri / - - [18/Feb/2011:05:38:49 +0000] [my.site.com/sid#7f273d77cb80][rid#7f273da48b28/initial] (3) applying pattern '^/([a-zA-Z0-9\-\_]+)/$' to uri '/' - - [18/Feb/2011:05:38:49 +0000] [my.site.com/sid#7f273d77cb80][rid#7f273da48b28/initial] (3) applying pattern '^/([a-zA-Z0-9\-\_]+)/([a-zA-Z0-9\-\_]+)/$' to uri '/' - - [18/Feb/2011:05:38:49 +0000] [my.site.com/sid#7f273d77cb80][rid#7f273da48b28/initial] (1) pass through / - - [18/Feb/2011:05:38:49 +0000] [my.site.com/sid#7f273d77cb80][rid#7f273da5a298/subreq] (2) init rewrite engine with requested uri /Director.php - - [18/Feb/2011:05:38:49 +0000] [my.site.com/sid#7f273d77cb80][rid#7f273da5a298/subreq] (2) rewrite '/Director.php' -> '-[L,NC]' - - [18/Feb/2011:05:38:49 +0000] [my.site.com/sid#7f273d77cb80][rid#7f273da5a298/subreq] (3) applying pattern '^/([a-zA-Z0-9\-\_]+)/$' to uri '-[L,NC]' - - [18/Feb/2011:05:38:49 +0000] [my.site.com/sid#7f273d77cb80][rid#7f273da5a298/subreq] (3) applying pattern '^/([a-zA-Z0-9\-\_]+)/([a-zA-Z0-9\-\_]+)/$' to uri '-[L,NC]' - - [18/Feb/2011:05:38:49 +0000] [my.site.com/sid#7f273d77cb80][rid#7f273da5a298/subreq] (2) local path result: -[L,NC]

Apache2 Access Log

my.site.com:443 - - [18/Feb/2011:05:44:19 +0000] "GET / HTTP/1.1" 400 3223 "-" "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8"

Any ideas? I don't know what else to try?


Here's my vhost conf:

RewriteEngine On
RewriteLog "/LiveWebs/mysite.com/rewrite.log"
RewriteLogLevel 5

# Dont rewite Crons folder
ReWriteRule ^/Crons/ - [L,NC]
ReWriteRule ^/phpmyadmin - [L,NC]
ReWriteRule .php$ -[L,NC]  # this is the problem!!

RewriteCond %{REQUEST_URI} !^/images/ [NC]
RewriteRule ^/([a-zA-Z0-9\-\_]+)/$ /Director.php?rt=$1 [L,QSA]

RewriteCond %{REQUEST_URI} !^/images/ [NC]
RewriteRule ^/([a-zA-Z0-9\-\_]+)/([a-zA-Z0-9\-\_]+)/$ /Director.php?rt=$1&action=$2 [L,QSA]

The problem is the line "ReWriteRule .php$ -[L,NC]". When I comment it out, the home page loads. The question is, how do I make URLS that actually end in .php go straight through (without breaking the home page)?

  • Error in rewrite rules. Add mod_rewrite config.
    – ooshro
    Commented Feb 18, 2011 at 6:13

1 Answer 1


It looks like not any rewrite rule will ever match / : in the two rewrite rules after the problematic one the "minimal" match is /./ and /././, so this two have no chance to match /.

You could add a rewrite rule specific to the url https://my.site.com/ just before the ".php" one :

 RewriteRule ^/$ /Director.php?rt= [L,QSA]

When you ask for / to your web server, it will serve the first page found with a name listed in the DirectoryIndex directive. If your DirectoryIndex contain index.php it is likely this page which is be catched by the rewrite rules actually.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .