Make urlManager config:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'' => 'site/zzz',
'index.php' => 'site/about',
'asd.php' => 'site/about',
'about' => 'site/about',
Request: http://localhost/index.php
'site/about' action result.
'site/zzz' action result.
If I request http://localhost/asd.php then I successfully get 'site/about' action result.
| Q | A
| ---------------- | ---
| Yii version | 2.0.18-dev
| PHP version | 7.3.4
| Operating system | Ubuntu
You probably need to rename your entry script to something else than index.php.
You probably need to rename your entry script to something else than
index.php.
It's not a good solution. Entry script must not affect on URL routing rules in "PrettiURL" mode.
Routing does not affect URLs to existing files. index.php is existing file.
Routing does not affect URLs to existing files.
It depends on HTTP server configuration.
If Yii accepts request, then it must route it, according to urlManager rules!
Route is based on path info. Path info is string between entry script and query string. For http://localhost/index.php path info is empty, since there is nothing after index.php. You would need to use http://localhost/index.php/index.php to pass index.php as path info.
Although it could make sense to change this behavior when showScriptName is off, it is probably too late for Yii 2 to do this (this sounds like big BC break).
@rob006 summed it well. It's rare case where index.php and / should be handled differently and it will break backwards compatibility very significantly if we'll change it. Thus, won't adjust it in 2.0.