当前位置: 首页 > news >正文

nginx模块ngx-fancyindex 隐藏标题中的 / 和遇到的坑

首先下载nginx源码,编译时加上 --add-module=/usr/local/src/ngx-fancyindex/

例如 : 

./configure --prefix=/usr/local/nginx --with-select_module --with-poll_module --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_v3_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module --with-http_sub_module --with-pcre --with-pcre-jit --with-debug --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-libatomic --add-module=/usr/local/src/ngx-fancyindex/

make && make install 安装完成

说说遇到的两个大坑,两个坑相辅相成

1. 需要将header.html,footer.html及其css文件放到根目录或者子目录才能生效

不能放到其他位置。就是放在nginx安装路径,一直改配置,但是css文件一直找不到。(就是因为html引用的css或者js文件,只能在根目录及其子目录中。),如果写<style>样式放哪应该都行,没试过。

2.目录浏览的根目录就是你nginx server下面配置的 root后面跟的路径

如下: 访问是ip:post/download ,但是根目录是/home/test/www,因此header和footer引用css文件的时候要注意,如果在/home/test/www/fancyindex下有一个header.html和styles.css,那么引用就应当是 <link rel="stylesheet" href="/fancyindex/styles.css">

 server53     {54         listen 18255 ssl  http2;  # 启用 HTTP/2 可以提高性能55         server_name localhost;56     65 66         root /home/test/www;67     68         location /download/ {69           access_log /www/server/nginx/logs/access.log;70            81             autoindex on;

说说怎么去掉页面上显示的/ ,我目前用的是开源主题Nginx-Fancyindex-Theme,这样改一下就好了,不用自己写。

我显示的/download/,难看死了,原理就是让写一个半开的标签,让其包括了目录路径,半开标签,fancyindex补齐另一半的时候路径也被包括在标签中,然后将这个标签隐藏掉,

header.html

    1 <!DOCTYPE html>2 <html>3     <head>4         <meta charset="utf-8">5         <meta http-equiv="x-ua-compatible" content="IE=edge">6         <title>eyoyou</title>7         <meta name="viewport" content="width=device-width, initial-scale=1">8         <link rel="stylesheet" href="/Nginx-Fancyindex-Theme-dark/styles.css">9         <script type="text/javascript" src="/Nginx-Fancyindex-Theme-dark/jquery.min.js"></script>10     </head>11 <body>12 <h1>存档下载<h1>13 <h6>index of

styles.css中

 h6 {45  display:none;46 }

去掉之前

去掉之后

http://www.lryc.cn/news/506838.html

相关文章:

  • 第二十四天 循环神经网络(RNN)LSTM与GRU
  • RocketMQ如何保证消息顺序?
  • LabVIEW实现GSM/GPRS通信
  • 关于如何做技术文档
  • 基于多尺度动态卷积的图像分类
  • RK3576 介绍
  • 如何评估并持续优化AI呼出机器人的使用效果
  • Ubuntu上如何部署Nginx?
  • 制造业4.0:AI与机器人如何重塑生产线
  • ChatGPT与领域特定语言的集成
  • 【记录50】uniapp安装uview插件,样式引入失败分析及解决
  • 【WPF】把DockPanel的内容生成图像
  • 买卖股票的最佳时机 - 合集
  • lshw学习——简单介绍
  • 深入理解Kafka:核心设计与实践原理读书笔记
  • OnOn-WebSsh (昂~昂~轻量级WebSSH) 可实现 网页 中的 ssh 客户端操作,支持多用户多线程操作 ssh 持久化
  • LDP+LBP代码解析及应用场景分析
  • 51c视觉~合集33
  • element plus的table组件,点击table的数据是,会出现一个黑色边框
  • springmvc的拦截器,全局异常处理和文件上传
  • 【coredump】笔记
  • 【Linux】磁盘空间莫名消失,找不到具体原因的思路
  • 智能体实战(需求分析助手)一、需求概述及迭代规划
  • idea | maven项目标红解决方案 | 强制刷新所有依赖
  • *【每日一题 基础题】 [蓝桥杯 2023 省 B] 飞机降落
  • 在Windows本地用网页查看编辑服务器上的 jupyter notebook
  • OpenCV圆形标定板检测算法findGrid原理详解
  • 自动图像标注可体验
  • 武汉市电子信息与通信工程职称公示了
  • Ansible基本用法