I
I
Iskander2017-01-26 16:36:25
Yii
Iskander, 2017-01-26 16:36:25

How to remove /site/ from yii link?

Hello. I think this is a beaten question. But all the solutions available on the Internet do not help me.
I have YII 1.1.16 . Pages only open if /site/ is specified. Let's say there is a page http://domain.ru/site/contacts , but it needs to be http://domain.ru/contacts. Please help, how can I implement this?
Writing rules manually for each page is not an option. Because it is possible to add pages from the admin panel, and there are more than 200 pages on the site.
.htaccess is now like this:

AddDefaultCharset utf-8
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

urlManager is like this:
'urlManager'=>array(
      'urlFormat'=>'path',
      'showScriptName'=>false,
      'rules'=>array(
        '<controller:site>/<action:card>/<alias:\w+>'=>'<controller>/<action>', 
        '<controller:\w+>/<id:\d+>'=>'<controller>/view',
        '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
        '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
      ),
    ),

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2017-01-26
@Lektor1

Good afternoon?
Have you tried to solve the problem yourself? How did you try to decide?
On google, the first link for "How to remove /site/ from yii link" is
here
PS
Try starting with the following:

'urlManager'=>array(
      'urlFormat'=>'path',
      'showScriptName'=>false,
      'rules'=>array(
               '' => 'site/index',
               '<_a:[\w\-]+>' => 'site/<_a>',
      ),
    ),

Нурлан, 2017-01-26
@daager

Yii urlManager скрыть 'index.php/site' из ссылки

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question