Nginx与子目录(Nginx with subdirectory)
我试图让以下配置在子目录/ dev中工作,但我对Nginx很新,似乎无法让它正常工作。
如果查看以下配置,您将看到子目录,例如内容 , 站点等。所有这些目录都位于另一个子目录/ dev中 。 例如: root / dev / content , root / dev / site等。
任何人都可以伸出援助之手,以便我可以正确访问/ dev网站吗?
# block content location ~ ^/content/(.*).(txt|md|mdown)$ { rewrite ^/content/(.*).(txt|md|mdown)$ /error redirect; } # block all files in the site folder from being accessed directly location ~ ^/site/(.*)$ { rewrite ^/site/(.*)$ /error redirect; } # block all files in the kirby folder location ~ ^/kirby/(.*)$ { rewrite ^/kirby/(.*)$ /error redirect; } # site links location / { try_files $uri $uri/ /index.php?$uri&$args; } # panel links location /panel { try_files $uri $uri/ /panel/index.php?$uri&$args; } # deny access to .htaccess files location ~ /\.ht { deny all; }I'm trying to get the following configuration to work inside a subdirectory /dev but I'm quite new to Nginx and can't seem to get it to work properly.
If you look at the below configuration, you'll see subdirectories such as content, site, etc. All of those directories are inside another subdirectory /dev. For example: root/dev/content, root/dev/site, etc.
Can anyone lend a hand so that I can access the /dev site properly?
# block content location ~ ^/content/(.*).(txt|md|mdown)$ { rewrite ^/content/(.*).(txt|md|mdown)$ /error redirect; } # block all files in the site folder from being accessed directly location ~ ^/site/(.*)$ { rewrite ^/site/(.*)$ /error redirect; } # block all files in the kirby folder location ~ ^/kirby/(.*)$ { rewrite ^/kirby/(.*)$ /error redirect; } # site links location / { try_files $uri $uri/ /index.php?$uri&$args; } # panel links location /panel { try_files $uri $uri/ /panel/index.php?$uri&$args; } # deny access to .htaccess files location ~ /\.ht { deny all; }最满意答案
添加/ dev大多数配置解决了它。
# block content location ~ ^/dev/content/(.*).(txt|md|mdown)$ { rewrite ^/dev/content/(.*).(txt|md|mdown)$ /error redirect; } # block all files in the site folder from being accessed directly location ~ ^/dev/site/(.*)$ { rewrite ^/dev/site/(.*)$ /error redirect; } # block all files in the kirby folder location ~ ^/dev/kirby/(.*)$ { rewrite ^/dev/kirby/(.*)$ /error redirect; } # site links location /dev { try_files $uri $uri/ /dev/index.php?$uri&$args; } # panel links location /dev/panel { try_files $uri $uri/ /dev/panel/index.php?$uri&$args; } # deny access to .htaccess files location ~ /\.ht { deny all; }Adding /dev to most of the config solves it.
# block content location ~ ^/dev/content/(.*).(txt|md|mdown)$ { rewrite ^/dev/content/(.*).(txt|md|mdown)$ /error redirect; } # block all files in the site folder from being accessed directly location ~ ^/dev/site/(.*)$ { rewrite ^/dev/site/(.*)$ /error redirect; } # block all files in the kirby folder location ~ ^/dev/kirby/(.*)$ { rewrite ^/dev/kirby/(.*)$ /error redirect; } # site links location /dev { try_files $uri $uri/ /dev/index.php?$uri&$args; } # panel links location /dev/panel { try_files $uri $uri/ /dev/panel/index.php?$uri&$args; } # deny access to .htaccess files location ~ /\.ht { deny all; }更多推荐
发布评论