jpsequeira
(Sequeira Jorgepaulo)
October 27, 2015, 12:44pm
1
I’ve got clean urls in place in yii 1.1.
My .htaccess is configured and it is the same in both versions.
My url config rules are the same in both versions.
Yet:
In yii 1.1 I can call an action this way:
http://mydomain/controler/view/id/1315.sk
(i use a suffix…)
While in Yii2 it only works if I call it like this:
http://mydomain/controler/view.sk?id=1315
I like the first form better.
is there a way I can have the same kind of url as in Yii 1?
What am I doing wrong?
jpsequeira
(Sequeira Jorgepaulo)
October 27, 2015, 2:40pm
2
After a litle more digging I found a config in my config.php in Yii 1 that goes like this:
‘urlFormat’=>‘path’,
Yet, the problema still remains.
It seems this setting doesn’t exist in Yii2.
Anyone knows what is the equivalent setting in Yii2?
Thank you in advance.
Bizley
(Bizley)
October 27, 2015, 4:23pm
3
jpsequeira
(Sequeira Jorgepaulo)
October 28, 2015, 10:04am
4
Of course I did. Still don’t getting it. That’s why I posted this topic!
Thank you for your answer anyway.
haidt
(Haidt3004)
October 28, 2015, 10:23am
5
Hello jorge sequeira,
You need to add 2 htaccess files here
htaccess file to -> root web folder with content
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ web/$1 [L]
</IfModule>
# Deny accessing below extensions
<Files ~ "(.json|.lock|.git)">
Order allow,deny
Deny from all
</Files>
# Deny accessing dot files
RewriteRule (^\.|/\.) - [F]
htaccess file to -> web/ folder with content
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Final is adding to config/web.php
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'baseUrl' => '/yii2',
'rules' => [
//your rules here
],
],
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'abc0123456789',
'baseUrl' => '/yii2',
],
Note : /yii2 is folder contain your site.
And you can access your site as your rules