需要帮助将.htaccess重写规则转换为nginx配置。规则来自metro缩小网址缩写脚本。.htaccess重写为nginx配置
RewriteEngine On
#RewriteBase/
RewriteRule ^developer.html$ developer.php [QSA,L]
RewriteRule ^multishrink.html$ multishrink.php [QSA,L]
RewriteRule ^stats.html$ public-stats.php [QSA,L]
RewriteRule ^feed.rss feed.php [QSA,L]
RewriteRule ^([^/]+)\.qrcode$ qrcode.php?id=$1 [QSA,L]
RewriteRule ^api.php$ API/simple.php [QSA,L]
RewriteRule ^API/write/(get|post)$ API/write.php?method=$1 [QSA,L]
RewriteRule ^API/read/(get|post)$ API/read.php?method=$1 [QSA,L]
RewriteRule ^([^/]+)/stats$ stats.php?id=$1 [QSA,L]
RewriteRule ^([^/]+)/unlock$ unlock.php?id=$1 [QSA,L]
# If path is not a directory or file then apply RewriteRule
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9a-zA-Z-]{1,60})$ go.php?id=$1 [QSA,L]
感谢回复,但我得到了两个错误1)无效参数“= 404”2)在“设置”指令 – user1624300
另一个错误[emerg] pcre_compile()失败失踪)中的参数无效“^([0-9a-zA- Z-]“ – user1624300
pcre_compile是因为正则表达式涉及的大括号也用于划分块,所以正则表达式必须被引用。在我的回答 – cobaco