首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将目录htaccess代码转换为nginx conf文件的语句

将目录htaccess代码转换为nginx conf文件的语句
EN

Stack Overflow用户
提问于 2020-04-23 21:46:55
回答 1查看 27关注 0票数 0

我正在尝试将数据库重写从htaccess directory语句重写到centOS7上的nginx服务器。我们从db的php参数知道它是有效的,比如/UBA/reports/index.php?type=b&name=league_100_home。

有人能帮我们翻译一下需要在nginx conf文件中添加什么才能让domain.ssl.conf正常工作吗?文件所在的文件夹位于/public/UBA/report/

我们尝试对nginx转换站点进行htaccess,但没有成功,并且conf文件无法使用nginx重新启动。下面的代码是目录/public/UBA/report/中的重写规则,它使apache服务器重写并工作。谢谢!

报表URL路径来自$reports_url_path =“/UBA/ reports /”的dbconfig.php文件;

代码语言:javascript
复制
RewriteOptions MaxRedirects=1
RewriteRule ^leagues/(.*)\.html$ '[%REPORTS_URL_PATH]index.php?type=b&name=$1' [L]


RewriteRule ^box_scores/(.*)\.html$ '[%REPORTS_URL_PATH]index.php?type=e&name=$1' [L]
RewriteRule ^coaches/(.*)\.html$ '[%REPORTS_URL_PATH]index.php?type=g&name=$1' [L]
RewriteRule ^game_logs/(.*)\.html$ '[%REPORTS_URL_PATH]index.php?type=f&name=$1' [L]
RewriteRule ^history/(.*)\.html$ '[%REPORTS_URL_PATH]index.php?type=h&name=$1' [L]
RewriteRule ^leagues/(.*)\.html$ '[%REPORTS_URL_PATH]index.php?type=b&name=$1' [L]
RewriteRule ^players/(.*)\.html$ '[%REPORTS_URL_PATH]index.php?type=d&name=$1' [L]
RewriteRule ^teams/(.*)\.html$ '[%REPORTS_URL_PATH]index.php?type=c&name=$1' [L]
EN

回答 1

Stack Overflow用户

发布于 2020-04-24 01:44:55

经过反复试验,我们用下面的代码解决了这个问题:

代码语言:javascript
复制
rewrite ^/UBA/reports/box_scores/(.*)\.html$ /UBA/reports/index.php?type=e&name=$1 last;
rewrite ^/UBA/reports/coaches/(.*)\.html$ /UBA/reports/index.php?type=g&name=$1 last;
rewrite ^/UBA/reports/game_logs/(.*)\.html$ /UBA/reports/index.php?type=f&name=$1 last;
rewrite ^/UBA/reports/history/(.*)\.html$ /UBA/reports/index.php?type=h&name=$1 last;
rewrite ^/UBA/reports/players/(.*)\.html$ /UBA/reports/index.php?type=d&name=$1 last;
rewrite ^/UBA/reports/teams/(.*)\.html$ /UBA/reports/index.php?type=c&name=$1 last;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61388811

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档