PHP伪静态

326 阅读1分钟

无意间看见这行代码,在nginx的vhosts.conf文件上按照文档的指导加了一行

try_files uriuri uri/ /index.php?$query_string; server { listen 80; server_name localhost;

root  D:/phpStudy/WWW/demo;
index index.php index.html index.htm;

location / {
    if (!-e $request_filename) {
         rewrite  ^/(.*)$  /index.php/$1  last;        
         break;
    }
    try_files $uri $uri/ /index.php?$query_string;
}

location ~ ^/s-([0-9a-z]+)-(.*) {
    rewrite ^/s-([0-9a-z]+)-(.*) /shtmls/$1/$2 last;
    break;
}

location ~ ^/desktop {
    rewrite  ^/(.*)$  /index.php/$1  last;
    break;
}

第二种: 解决方法:我使用的是Nginx,所以就就改了一下conf文件:

location / {
    if (!-e $request_filename) {
        rewrite  ^(.*)$  /index.php?s=/$1  last;
    }
}

在location / {  }中添加上这段代码后,重启nginx服务就可以了。

 

如果使用宝塔面板,就非常方便了,在网站的编辑中,在<伪静态>一项中添加上,重启服务就可以了。