rewrite实现伪静态
下面用到的包
👇👇👇👇👇👇👇👇👇
链接:https://pan.baidu.com/s/1q7sXw6m80LyrZpFO4LumaA
提取码:6666
[root@web01 ~]# mkdir /code/discuz
[root@web01 /code]# cd /code/discuz
[root@web01 /code/discuz]# rz
[root@web01 /code]# unzip Discuz_X3.3_SC_GBK.zip -d /code/discuz/
#授权
[root@web01 /code]# chown -R www.www /code/discuz/
[root@web01 /code]# vim /etc/nginx/conf.d/linux.discuz.com.conf
server {
listen 80;
server_name linux.discuz.com;
root /code/discuz/upload;
location / {
index index.php index.html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
[root@web01 /code]# nginx -t
[root@web01 /code]# systemctl restart nginx
#配置hosts
10.0.0.7 nginx.rewrite.com linux.discuz.com
[root@db01 ~]# mysql -uroot -pLinhd@123
MariaDB [(none)]> create database discuz;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on discuz.* to discuz@'172.16.1.%' identified by '123456';
Query OK, 0 rows affected (0.01 sec)
[root@web01 /code]# cat /etc/nginx/conf.d/linux.discuz.com.conf
server {
listen 80;
server_name linux.discuz.com;
root /code/discuz/upload;
location / {
index index.php index.html;
}
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/archiver/index.php?action=$2&value=$3 last;
rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
if (!-e $request_filename) {
return 404;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
http://linux.discuz.com/forum-2-1.html
http://linux.discuz.com/forum.php?mod=forumdisplay&fid=2&page=1
配置页面


如何寻找rewrite


本文来自博客园,作者:六月OvO,转载请注明原文链接:https://www.cnblogs.com/chenlifan/p/13617635.html

浙公网安备 33010602011771号