Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my controller requesting frontend_dev.php in Symfony?

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?

like image 532
user198729 Avatar asked Feb 28 '23 13:02

user198729


1 Answers

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.

like image 87
Raise Avatar answered Mar 07 '23 04:03

Raise