views:

243

answers:

2

http://localhost/frontend_dev.php/1

Why is the above request redirected to frontend_dev.php instead of index.php?

I've read the .htaccess:

<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>

If I'm understanding it correctly,if the requested file doesn't exist,it should be redirected to index.php,how can frontend_dev.php be run in the case above?

+2  A: 

Simple. Because frontend_dev.php does exist, it is executed. And no redirect is performed.

develop7
Shouldn't the file be `frontend_dev.php/1` ?
No it shouldn't. I can't exactly say why, but probably Apache docs could shed the light on this issue.
develop7
+6  A: 

You have specified http://localhost/frontend_dev.php/1 as the URL - Apache simply serves up frontend_dev.php as you are explicitly asking for that file in the URL. Change your URL to http://localhost/index.php/1 to see the production controller.

The rewrite rules deal only with URLs that don't mention a front controller at all, ie. http://localhost/1 - the rewrite rules are not being parsed at all for the URL you initially provided, as Apache detected the frontend_dev.php file and found no matching rewrite rule to parse.

Raise
+1 Very good answer
Jon Winstanley