由于LimeSurvey是使用yii框架,所以短链的设置
LimeSurvey的配置文件位于“/根目录/application/config”下,名为config.php。
一、隐藏index.php
找到如下的代码'showScriptName' => true,
并修改成'showScriptName' => false,
。
刷新一下页面就会发现地址栏中的index消失不见了。
二、修改
根据官网上的设置,修改config.php(位于根目录/application/config中)
'urlManager' => array(
'urlFormat' => 'path',
'rules' => array(
'<sid:\d+>' => array('survey/index','urlSuffix'=>'.html','matchValue'=>true),
),
'showScriptName' => false,
),
网页的链接变为xxx.html?lang=zh-Hans,并显示错误。
修改nginx配置文件如下:
server {
set $host_path "/PATH/TO/LIMESURVEY";
server_name YOUR.SERVER.FQDN;
root /PATH/TO/LIMESURVEY;
charset utf-8;
try_files $uri /index.php?$args;
location ~ ^/(protected|framework|themes/\w+/views) {
deny all;
}
#avoid processing of calls to unexisting static files by yii
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
try_files $uri index.php;
fastcgi_pass 127.0.0.1:9000; # Change this to match your settings
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
并重新加载配置文件,刷新页面直接空白,连错误提示都没有。
location ^~ /survey {
access_log off;
error_log /home/usuario/logs/survey.error.log;
set $host_path "/home/usuario/public_html/survey";
root /home/usuario/public_html;
try_files $uri /survey/index.php?$args;
location ~ \.php {
include /etc/nginx/fastcgi_params;
fastcgi_pass php5-fpm;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
以上来自https://blog.heitorsilva.com/en/php/rewrite-de-nginx-para-limesurvey/
参考文档: