How can I change my base url : http://mydomin/ProjectName/frontend/web/index.php?r=product/index
to something like this http://mydomin/product/index
? I read many articles about this topic but none of it proof useful. I also tried the following:
(1) enable prettyUrl in my config file at frontend/config/main.php and I added some rules as I read from an article..
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'product/<controller:\w+>/<action:[\w-]+>/<id:\d+>' => 'product/<controller>/<action>',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
],
],
(2) I created a .htaccess file at my web directory at /frontend/web/.htaccess and I added the below code:
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
Now, when I try to access http://mydomin/ProjectName/frontend/web/product/index
I got error message: The requested URL /ProjectName/frontend/web/product
was not found on this server. if I comment out 'showScriptName' => false
, in the urlManager setting it works in this format http://mydomin/ProjectName/frontend/web/index.php/product/index
it stripe off the ?r=
but still have the index.php
file..
how can I do it to hide this file and even hide all app folder like projectName, frontend,and web folder
so at the end instead of http://mydomin/ProjectName/frontend/web/index.php/product/index
or http://mydomin/ProjectName/frontend/web/index.php?r=product/index
I will just get http://mydomin/product/index