Sanjay Chaudhari
Sanjay Chaudhari

Reputation: 420

URL manager issue in yii2

This is my backend url : http://localhost/game_website_new/phase1/admin/ and its working fine but,

Now I have a forum folder in my application directory and it will accessible in frontend like this : http://localhost/game_website_new/phase1/forum Working.

But I want to use forum in backend like this : http://localhost/game_website_new/phase1/admin/forum and this is not working.

below is my site .htaccess file

# prevent directory listings
Options -Indexes
IndexIgnore */*

# follow symbolic links
Options FollowSymlinks
RewriteEngine on
RewriteRule ^admin(.+)?$ backend/web/$1 [L,PT]
RewriteRule ^(.+)?$ frontend/web/$1

Upvotes: 2

Views: 248

Answers (1)

Vladyslav Startsev
Vladyslav Startsev

Reputation: 379

you can do it by going to config (if you use advanced app in will be common/config) folder of your app and open web.php or main.php there you will see something like this.

$config = [
      'urlManager' => [
      //some configs here
      ],

search for 'urlManager' to find your config file.

read some doc's on it http://www.yiiframework.com/doc-2.0/guide-runtime-routing.html

I think it you situation this should work

$config = [
    'urlManager' => [
                'enablePrettyUrl' => true,
                'showScriptName' => false,
                'enableStrictParsing' => false,
                'rules' => [
                    //you can use regexp in parameters
                    'your/new/url/<parameterId:\d+>' => 'old/url', // old url will match something like moduleIfYouHaveOne/YourController/YourAction
                    'phase1/admin/forum' => 'phase1/forum',
                ],

Upvotes: 1

Related Questions