将Nginx Config转换为Apache2 Config

时间:2019-02-12 14:07:54

标签: nginx apache2

我正在努力将nginx配置转换为apache2配置。

我的nginx-config(正在工作):

server {
listen 8083;

# redirect / non terminated requests on context path
location = /media {
return 302 /media/;
}

# remove context /media from path
location /media/ {
  rewrite ^/media(/.*)$ $1 last;
}

# Prevent download of files starting with .
location ~ (^/\..*) {
  return 403;
}

# Set location of files
location / {
  root /data/mediadata;
}

}

尝试转换为apache2-config:

Listen 8083

User media
Group media


<VirtualHost *:8083>
RewriteEngine On
DocumentRoot /data/mediadata
ErrorLog /var/log/vhosts/mediadata_error.log
TransferLog /var/log/vhosts/mediadata_transfer.log
CustomLog /var/log/vhosts/mediadata_access.log combined
DumpIOOutput On
LogLevel rewrite:trace8

  <Location "/media"> 
    Redirect 302 "/media" "/media/"
  </Location>
  <LocationMatch "^/media/(.*)">
    RewriteRule ^(.*?)/?$ /cache/$1 [L]
    RewriteRule ^media(/.*)$ $1 [L]
    Require all granted
  </LocationMatch>

  <LocationMatch "(^/media/\..*)">
     RedirectMatch 403 (^/\..*)
  </LocationMatch>
</VirtualHost>

我阅读了扩展日志,由于/data/mediadata/media/example.txt导致文件不存在。正确的路径应为/data/mediadata/example.txt

谢谢。

0 个答案:

没有答案