0

我有一个运行 Apache 的实时服务器和一个在 docker 中运行 NGINX 的开发服务器。我希望将我的网站网址从 重写/index.php?t=123abc/123abc

此规则似乎在 .htaccess 中有效

RewriteRule ^([0-9a-f]{6})$ index.php?t=$1 [L]

但是,我无法将其转换为 nginx 指令。我的“默认”站点配置是:

server {
    listen 80 default_server;
    listen 443 ssl;

    root /config/www;
    index index.html index.htm index.php;

    server_name _;

    ssl_certificate /config/keys/cert.crt;
    ssl_certificate_key /config/keys/cert.key;

    client_max_body_size 0;

    location / {
        rewrite "^/([0-9a-f]{6})/?$" "/index.php?t=$1";
        try_files $uri $uri/ =404;
    }
    autoindex on;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        # With php5-cgi alone:
        fastcgi_pass 127.0.0.1:9000;
        # With php5-fpm:
        #fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;

    }

}

工作正常,/index.php?t=123abc/123abc给出 404 错误。

请帮忙

4

0 回答 0