Why does my controller request 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 read .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 understand correctly, if the requested file does not exist, it should be redirected to index.php , how can frontend_dev.php be executed in the above case?

+4
source share
2 answers

You have specified http: //localhost/frontend_dev.php/1 as the URL. Apache just serves up frontend_dev.php as you explicitly request this file in the URL. Change your URL to http: //localhost/index.php/1 to see the production controller.

Rewriting rules include only URLs that do not mention the front controller at all, i.e. http: // localhost / 1 - rewrite rules are not processed at all for the URL that you originally provided, because Apache detected the file frontend_dev.php and found there is no corresponding rewrite rule for parsing.

+6
source

Simple Since frontend_dev.php exists, it executes . And the redirection is not performed.

+2
source

Source: https://habr.com/ru/post/1301604/


All Articles