Page 1 of 1

mod_rewrite. What's a "-" by itself mean?

Posted: Mon Apr 23, 2007 9:46 am
by Chris Corbyn
In the symfony .htacess file to get the Routing configuration working they have this:

Code: Select all

Options +FollowSymLinks +ExecCGI

<IfModule mod_rewrite.c>
  RewriteEngine On

  # uncomment the following line, if you are having trouble
  # getting no_script_name to work
  RewriteBase /

  # we skip all files with .something
  RewriteCond %{REQUEST_URI} \..+$
  RewriteCond %{REQUEST_URI} !\.html$
  RewriteRule .* - [L]

  # we check if the .html version is here (caching)
  RewriteRule ^$ index.html [QSA]
  RewriteRule ^([^.]+)$ $1.html [QSA]
  RewriteCond %{REQUEST_FILENAME} !-f

  # no, so we redirect to our front web controller
  RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

# big crash from our front web controller
ErrorDocument 500 "<h2>Application error</h2>symfony application failed to start properly"
Now, the following line is causing issues for me:

Code: Select all

RewriteRule .* - [L]
Basically it's stopping me from being able to use query strings that end in ".php".

I'll explain.

Symfony takes my URL:

http://trunk.swiftmailer.org/source/Swi ... ending.php

Which actually points to this real URL (note the index.php/path)

http://trunk.swiftmailer.org/index.php/ ... ending.php

Symfony then does some further processing the route the request in the front controller.

It does work if I map something like:

http://trunk.swiftmailer.org/source -> http://trunk.swiftmailer.org/index.php/source

But with the first example where a ".php" exists and the end if the URI I just get a 404 from apache. Taking out the "RewriteRule .* - [L]" fixes the issue but I'd like to know what that rule actually does so I can be sure I'm not breaking anything by removing it. Maybe there's a longer way to write the same rule?

Cheers :)

EDIT | I have read the apache documentation for mod_rewrite but didn't see it in there.

Posted: Mon Apr 23, 2007 11:12 am
by JayBird
I have never seen a "-" used like that before. Are you sure it is valid.

I cant see any reference to it in any of my mod_rewrite sources.

Posted: Tue Apr 24, 2007 9:06 am
by Chris Corbyn
JayBird wrote:I have never seen a "-" used like that before. Are you sure it is valid.

I cant see any reference to it in any of my mod_rewrite sources.
I couldn't find any reference to it neither. I'm leaving it commented out for now and I'll just monitor what happens. I posted at the symfony forum but nobody replied.

Posted: Tue Apr 24, 2007 9:13 am
by feyd
I would assume it means a null result. i.e. it tanks the request. That should only happen when there is a dot in the request followed by any other characters that isn't "html."