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

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

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

Post 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.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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."
Post Reply