您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
lesson4 添加和管理文章及其分类和标签(固定链接 二级目录/子目录 nginx rewrite 伪静态)
发布时间:2023-02-11 22:53:34编辑:雪饮阅读()
Step1
后台地址:
Wordpress项目路径/wp-admin/
如:
控制板 ‹ WordPress教程网 — WordPress
Step2
修改管理员密码
添加新用户
用户列表(作者和用户)
模板也叫主题
修改博客标题和博客副标题(在站点首页有生效后的效果)
Step3
关于固定链接配置如:
/%year%/%monthnum%/%day%/%category%/%postname%/%post_id%.html
也就是访问文章页的url为“年/月/日/分类/文章名/文章id”的方式
则如果是nginx的配置则如:
server {
listen 80;
server_name localhost;
root "D:/phpstudy_pro/WWW";
location /wpcourse/ {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /wpcourse/index.php;
}
}
location / {
index index.html index.php;
if (-f $request_filename) {
break;
}
if (!-e $request_filename) {
rewrite . /index.php last;
}
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
这份配置是基于小皮面板8.1.13的默认站点localhost的配置文件如:
D:\phpstudy_pro\Extensions\Nginx1.15.11\conf\vhosts\0localhost_80.conf的这个配置文件修改的。
按理来说也应该可以,由于我这里使用了二级目录,否则可以直接用官方的那个配置。这里需要注意的是二级目录的那段配置需要在”/”配置段之前。
本次配置所处环境:
小皮面板8.1.13运行在win11x64,所运行的nginx为1.15.11,wordpress版本为2.8.5,php为5.3.29nts
关键字词:固定链接 ,二级目录,子目录,nginx,rewrite,伪静态