{"title":"Nginx 重定向到子目录的 index.html 文件","description":"使用 Nginx 配置将所有访问 /child/ 开头的 URL 重定向到 /child/index.html 文件,实现网站子目录的重定向功能。","keywords":"Nginx, 重定向, 子目录, index.html, 网站配置, URL 重写","content":"要将 nginx 重定向到 child 目录的 index.html 文件,您可以使用以下配置:\n\n\nserver {\n listen 80;\n server_name example.com;\n\n location / {\n root /path/to/parent;\n index index.html;\n }\n\n location /child {\n rewrite ^/child/(.*)$ /child/index.html break;\n }\n}\n\n\n在上面的配置中,我们首先设置了根目录为父目录的路径,并指定了 index.html 为默认索引文件。然后,在名为 /child 的位置块中,我们使用 rewrite 指令将所有 /child/ 开头的 URL 重定向到 /child/index.html 文件。\n\n请确保将 /path/to/parent 替换为您实际的父目录路径,并将 example.com 替换为您的域名。"}

Nginx 重定向到子目录的 index.html 文件

原文地址: https://www.cveoy.top/t/topic/pEgg 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录