douxingmou4533 2017-09-08 10:52
浏览 33

Yii 1.1路径无法在远程服务器上运行

I'm new to Yii and i'm having troubles setting up the config on a remote server. Locally, everything works great, but on the server, using the exact same GH repo including config/main.php, none of the links seem to work.

for example , in site/index, i have a link to /video/index however, whenever i click the link, the path is added like : /site/video/index. and pressing it repeatedly will add more /video/ in front.(/site/video/video/video/video/index). ->note this only happens on the server and not locally.

things that i've tried: manually inserting pretty and ugly urls in the browser bar, nothing worked. actually, anything i add after .com (.com/asdfbfdgvdipgfbsd/ ) will just render the site/index page, with the path i write remaining in the bar, but content being not an error or anything else, just my main index file.

how i managed to access the videos page:

  1. setting 'defaultUrl' => '/video/index' (instead of site/index), but this doesn't help as obviously i can only access this page now.

  2. commenting out 'urlFormat'=>'path' ----> this allows me to get to the video page from my site/index page , but this results in the following path displayed in the browser: /video/?r=video/index. Now, in this page i display 20 video thumbnails and have included a self-loading gallery (magicScroller). locally it works fine, more thumbs being added as i scroll down. however, in this config from the server, instead of more thumbs being rendered, i am getting /site/index page rendered below the first videos batch.

here is my 'components'->UrlManager from main.php config file:

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

i tried adding 'enablePrettyUrl'=>true, but this results in the error: Property "CUrlManager.enablePrettyUrl" is not defined.

note. locally everything works perfect, paths look normal (no double /video/video or anything peculiar)

Not sure what else to check and try so looking forward to hearing from this community of brilliant minds:)

EDIT: here is the config. maybe it sheds a bit of light on my issue

 server {
     listen       80;
     server_name my.site.com;

     #charset koi8-r;
     access_log  /var/log/nginx/my.site.com.access main;
     root   /www/my.site.com/public;

     location / {
         index  index.html index.php;
         try_files $uri $uri/ index.php?$args;
     }

     error_page  404              /404.html;

     # redirect server error pages to the static page /50x.html
     #
     error_page   500 502 503 504  /50x.html;
     location = /50x.html {

     }

     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
     location ~ \.php {
          fastcgi_split_path_info  ^(.+\.php)(.*)$;

          #let yii catch the calls to unexising PHP files
          set $fsn /index.php;
          if (-f $document_root$fastcgi_script_name){
              set $fsn $fastcgi_script_name;
          }

          #fastcgi_pass   127.0.0.1:9000;
          fastcgi_pass   unix:/var/run/fastcgi.sock;
          include fastcgi_params;
          fastcgi_param  SCRIPT_FILENAME  $document_root$fsn;

          #PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies  them for CGI
          fastcgi_param  PATH_INFO        $fastcgi_path_info;
          fastcgi_param  PATH_TRANSLATED  $document_root$fsn;
     }

     location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml|map)$ {
         try_files         $uri $uri/ =404;
         #log_not_found     off;
         expires           1d;
     }

     # deny access to .htaccess files, if Apache's document root
     # concurs with nginx's one
     #
     #location ~ /\.ht {
     #    deny  all;
     #}
 }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)