Resolved: Yii2 showScriptName remove index.php Not Found apache
I tried to remove index.php from url by many ways, but without results.
My OS is Ubuntu Linux.
Server Apache.
In web.php in config directory
Still not working
I try to created .htaccess in web direcory
Still without result
In result
404 Not Found
Please help me to resolve problem
My OS is Ubuntu Linux.
Server Apache.
In web.php in config directory
<?php
$config = [
'components' => [
'urlManager' => [
'class' => 'yii\web\UrlManager',
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'/' => 'site/index',
'login' => 'site/login',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
],
],
]
]
Still not working
I try to created .htaccess in web direcory
RewriteEngine on
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php
Still without result
In result
404 Not Found
Not Found
The requested URL /login was not found on this server.
Apache/2.4.18 (Ubuntu) Server at tracker.dev Port 80
Please help me to resolve problem
One comment
1. Open your terminal
2. Enable your mod_rewrite by command
3. Open your config file for your website by command
where tracker.dev is my project config name
4. In your config file you will see your configuration, for example
edit your config and add these part of config
in result
5. Don't forget to check your .htaccess in your web directory
6. Save and close config file, and restart apache2
7. Run(open) your links and urls again
and enjoy
Leave a Comment