0

This is my folder structure

-api
   -config
      main.php
   -web
      .htaccess

-backend
   -config
      main.php
   -web
      .htaccess

-frontend
    -config
      main.php
   -web
      .htaccess

in my api/main.php I enabled pretty url. This is my url manager

'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'rules' => [
        [
            'class' => 'yii\rest\UrlRule',
            'controller' => [
                'user',
                'site'
            ],
            'extraPatterns' => [
                'POST,OPTIONS search' => 'search',
                'GET site/error'=>'error'

            ]
        ],
    ],
],

and I configured my api/web/.htaccess also

RewriteEngine On
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php

but for every url I am getting the default site/index result. When I remove pretty url code it is working also code it is working in my local,but not working in my server. Do I need to change anything in .htaccess ? my yii-app url in server is like www.servername/my-yii-app/api/web. Any idea?

Ebin Manuval
  • 1,235
  • 14
  • 33
  • If similar code is working different in different machines, I assume that your web-server settings are different. Maybe htaccess is ignored in your server so that it leads to malfunction. You should check AllowOverride if it is set correctly.. – Yerke Feb 05 '17 at 20:36
  • I second this, AllowOverride might not be allowed on the server. Also you can set up an equivalent of .htaccess content in the vhosts files, maybe your server needs that. – Mihai P. Feb 06 '17 at 00:44
  • Check is mod_rewrite enabled on your server? – Alexey Berezuev Feb 06 '17 at 08:21
  • Yes it is enabled – Ebin Manuval Feb 06 '17 at 08:45

0 Answers0