简体   繁体   中英

Convert directory htaccess code in to statement for nginx conf file

I am trying to get a database rewrite to work from an htaccess directory statement to an nginx server on centOS7.. We know it works from the php argument from the db such as /UBA/reports/index.php?type=b&name=league_100_home

Could someone please help us translate what needs to be added in the nginx conf file for domain.ssl.conf for this to work properly? The folder where the files live are in /public/UBA/reports/

We tried an htaccess to nginx converter site with no success and the conf file failed to restart with nginx. The code below is the rewrite rules in the directory /public/UBA/reports/ that makes apache server rewrite & work. Thank you!

The reports URL path is from a dbconfig.php file with $reports_url_path = "/UBA/reports/";

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]

We solved this after trial and error with the following code:

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM