gpt4 book ai didi

.htaccess - 将 htaccess 转换为 nginx

转载 作者:行者123 更新时间:2023-12-03 10:48:19 25 4
gpt4 key购买 nike

关闭。这个问题是off-topic .它目前不接受答案。












想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。

8年前关闭。




Improve this question




我没有运气将 htaccess 规则转换为 nginx 重写。我已经查看了 NginxRewriteModule 文档并完成了一些,但更复杂的我不知所措。这是我在看的:

RewriteRule    ^$                                               /cgi-bin/index.cgi [L]
RewriteRule ([0-9A-Za-z]{12})-del-([0-9A-Za-z]+)/.+$ /cgi-bin/index.cgi?del=$1-$2 [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^([0-9A-Za-z]{12})(\.html?|$)$ /cgi-bin/index.cgi?op=download1&id=$1 [L]
RewriteRule ^([0-9A-Za-z]{12})(\/.+|\.html?|$) /cgi-bin/index.cgi?op=download1&id=$1&fname=$2 [L]
RewriteRule ^([0-9A-Za-z\-_]{4,64})/([0-9A-Za-z]{12})$ /cgi-bin/index.cgi?op=download1&usr_login=$1&id=$2 [L]
RewriteRule ^([0-9A-Za-z\-_]{4,64})/([0-9A-Za-z]{12})(\/.+|\.html?|$) /cgi-bin/index.cgi?op=download1&usr_login=$1&id=$2&fname=$3 [L]

#RewriteRule ^Reseller\.html$ /cgi-bin/Templates/Pages/english/Reseller.html [L]
RewriteRule ^checkfiles\.html$ /cgi-bin/index.cgi?op=checkfiles [L]
RewriteRule ^contact\.html$ /cgi-bin/index.cgi?op=contact [L]
RewriteRule ^premium\.html$ /cgi-bin/index.cgi?op=payments [L]
RewriteRule ^login\.html$ /cgi-bin/index.cgi?op=login [L]
RewriteRule ^catalogue(.*)\.html$ /cgi-bin/index.cgi?op=catalogue&date=$1 [L]
RewriteRule ^news([0-9]*)\.html$ /cgi-bin/index.cgi?op=news&page=$1 [L]
RewriteRule ^n([0-9]+)-.*\.html$ /cgi-bin/index.cgi?op=news_details&news_id=$1 [L]
RewriteRule ^free([0-9]+)\.html$ /cgi-bin/index.cgi?op=registration&aff_id=$1 [L]
RewriteRule ^users/([0-9A-Za-z\-_]{4,64})/?([0-9]+|$) /cgi-bin/index.cgi?op=user_public&usr_login=$1&fld_id=$2 [L,NC]
RewriteRule ^embedmp3-([0-9A-Za-z]{12})\.html$ /cgi-bin/index.cgi?op=mp3_embed&file_code=$1 [L]
RewriteRule ^embedmp4-([0-9A-Za-z]{12})\.html$ /cgi-bin/index.cgi?op=mp32_embed&file_code=$1 [L]
RewriteRule ^box$ /cgi-bin/index_box.cgi [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9A-Za-z\-_]{4,64})(/[^\/]*/?|$)$ /cgi-bin/index.cgi?op=user_public&usr_login=$1&fld=$2 [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z0-9\-\_]+).html(.*) /cgi-bin/index.cgi?op=page&tmpl=$1$2 [L]

最佳答案

将 Apache .htaccess 转换为 Nginx 重写工具的在线工具包括:

  • http://winginx.com/htaccess
  • http://www.anilcetin.com/convert-apache-htaccess-to-nginx/

  • 请注意,这些工具将转换为等效的 rewrite expressions使用 if语句,但它们应转换为 try_files .看:
  • http://wiki.nginx.org/NginxHttpCoreModule#try_files
  • 关于.htaccess - 将 htaccess 转换为 nginx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5840497/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com