咨询热线:4006-75-4006
售前:9:00-23:30 备案:9:00-18:00 技术:7*24h
环境
Ubuntu 14.04+Nginx+MySQL。所有程序都是通过apt-get安装的,所以Nginx的配置文件路径在/etc/nginx/sites-available/default。
解决方法
定位到Nginx配置文件的如下部分:
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
加入下面的代码:
if (!-e $request_filename)
{
rewrite ^/myapp/(.*)$ /myapp/index.php?s=$1 last;
break;
}
正则的写法
解决这个问题的时候,看到了好几种解决方案,光正则就看到了好几个,也不知道到底哪个是最标准的,本人正则也不是很熟,先记录下来,以后慢慢研究:
正则1:
rewrite ^/MYAPP/(.*)$ /MYAPP/index.php/$1 last;
正则2:
rewrite ^(.*)$ /index.php?s=$1 last;