全球主机交流论坛

标题: 请教老哥们关于NGINX跳转的规则 [打印本页]

作者: reebor    时间: 2021-4-10 15:11
标题: 请教老哥们关于NGINX跳转的规则
想访问 www.domain.com/index.php?m=vod-search-starring-刘德华 直接跳转到 www.domain.com/vosh/-刘德华------------.html

应该怎么写,我试了好多写法都不对,求老哥们给个完整的写法,跪谢!!!

location / {
    rewrite ^/index.php?m=vod-search-starring-(.*)$ /vosh/-$1------------.html redirect;
    }
作者: weshen    时间: 2021-4-10 15:19
不知道。但是我知道php不应该这样写。
作者: reebor    时间: 2021-4-10 15:35
weshen 发表于 2021-4-10 15:19
不知道。但是我知道php不应该这样写。

嗯,我想知道nginx 怎么写
作者: yep    时间: 2021-4-10 16:51
rewrite ^/index.php\?m=vod-search-starring-(.*)$ /vosh/-$1------------.html redirect;
这样试试呢,不知道有没有用
作者: reebor    时间: 2021-4-10 17:38
yep 发表于 2021-4-10 16:51
rewrite ^/index.php\?m=vod-search-starring-(.*)$ /vosh/-$1------------.html redirect;
这样试试呢,不 ...

也不行
作者: weshen    时间: 2021-4-10 18:29
reebor 发表于 2021-4-10 15:35
嗯,我想知道nginx 怎么写

你这个不是写在 location / 里,应该是php的查询条件。
作者: weshen    时间: 2021-4-10 18:31
weshen 发表于 2021-4-10 18:29
你这个不是写在 location / 里,应该是php的查询条件。

location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass   unix:/run/php/php7.4-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

类似 SCRIPT_FILENAME 这个,我感觉,不太懂。
作者: reebor    时间: 2021-4-10 19:53
weshen 发表于 2021-4-10 18:31
location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass   unix:/run/php/php7 ...

研究了一天没搞好,




欢迎光临 全球主机交流论坛 (https://loc.wget.at/) Powered by Discuz! X3.4