.htaccess 将htaccess转换为nginx
我无法将htaccess规则转换为nginx重写。我已经查阅了NginxRewriteModule文档并完成了一些工作,但对于更复杂的文档,我感到不知所措。以下是我所看到的:.htaccess 将htaccess转换为nginx,.htaccess,nginx,rewrite,.htaccess,Nginx,Rewrite,我无法将htaccess规则转换为nginx重写。我已经查阅了NginxRewriteModule文档并完成了一些工作,但对于更复杂的文档,我感到不知所措。以下是我所看到的: RewriteRule ^$ /cgi-bin/index.cgi [L] RewriteRule ([0-9A-Za-z]{12})-del-([0-9A-Za-z]+)/.+$ /cgi-bin/in
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]
重写规则的编写方式与nginx基本相同:
哪些规则给你带来了麻烦?我可以帮你翻译这些 用于翻译Apache.hts的在线工具Nginx重写工具包括:
if
语句转换为等效工具,但它们应转换为try\u文件
。见:
$content = $_POST['content'];
$lines = explode(PHP_EOL, $content);
$results = '';
foreach($lines as $line)
{
$items = explode(' ', $line);
$q = str_replace("^", "^/", $items[1]);
if (substr($q, strlen($q) - 1) !== '$') $q .= '$';
$buffer = 'rewrite "'.$q.'" "'.$items[2].'" last;';
$results .= $buffer.PHP_EOL;
}
die($results);
还没有测试过,但是外观比Alex提到的要好 网站上的描述是: 关于 该服务将Apache的.htaccess转换为nginx配置指令 首先,该服务被认为是对nginx转换器的mod_重写。但是,它允许您转换其他一些有理由从Apache移植到nginx的指令 注意:忽略服务器指令(例如php_值等) 转换器不检查语法,包括正则表达式和逻辑错误 请在使用前手动检查结果 使用以下命令:
在线转换器,很好的方式和节省时间;) 令人遗憾的是,一个半途而废的回答被轻率的评论所伤害。我已经把它删掉了。不管怎样,这个答案作为一个快速解决方案可能是一个救命稻草,但最好不要这样重写。特别是电子商务网站。请看这篇文章,这篇文章似乎对我不起作用,但这篇文章确实起了作用:这篇文章对我也不起作用。我尝试了一个非常基本的重写规则。你能告诉我,我应该在哪里使用输出吗?在php文件中?我用过,它给了我一个包含
的输出,如果
,现在我想知道我应该如何使用它?对or更好。winginx.com/htaccess not work昨天注意到它现在不工作了,是的。希望它能重新上线。如果你仔细看,你会发现我在你之前就已经发布了那个链接。。