扩展 realurl - 在 URL 中显示 SQL 个查询部分

Extension realurl - display of SQL query parts in URL

首先,我要处理一个TYPO3版本的项目相关升级,对Nginx web服务器也比较陌生

我已将 TYPO3 安装从 7.6-LTS 版本升级到 8.7-LTS,并将站点从 IIS (Windows) 服务器转移到带有 Nginx 的 Ubuntu 18.04 系统。

我现在发现了以下内容:首先单击菜单中网站上的内部 link,例如domain.com/prices 工作正常。 URL domain.com/prices 被调用并显示在 URL 中。现在,当页面重新加载后,相同的菜单项 link 现在看起来像这样...

domain.com/index.php?id=8&L=1%20or%20%281%2C2%29%3D%28select%2Afrom%28select%20name_const%28CHAR%28111%2C108%2C111%2C108%2C111%2C115%2C104%2C101%2C114%29%2C1%29%2Cname_const%28CHAR%28111%2C108%2C111%2C108%2C111%2C108%2C111%2C115%2C104%2C101%2C114%29%2C1%29%29a%29%20- -%20and%201%3D1 

...而不是通常的 domain.com/prices。页面的内容仍然正确,因此正在加载正确的页面。

Typo3 安装使用扩展名 real url,这正是用于此功能的。它将 domain.com/index.php?id=8&L=1... 翻译成像 domain.com/prices 这样的口语 url。那么为什么它在第一次加载时工作,但后来就不再工作了?

我也想过,可能是Nginx配置的问题,不过现在我觉得这里是另外一个话题了,因为如果是webserver的问题,第一次是不行的吧?

什么会导致这种行为?

更新

我确实看到,该网站的英文版运行良好。所以在这里,links 正确显示:domain.com/pricesdomain.com/modules,甚至没有第一页加载。

也许有用。这是Nginx配置,我目前使用:

server {
    listen 80;
    server_name domain.com;
    root /var/www/domain.com/public;
    index index.php index.html index.htm index.nginx-debian.html;

    listen 443 ssl;
    ssl_certificate /var/www/domain.com/ssl/domain.com-2020.crt;
    ssl_certificate_key /var/www/domain.com/ssl/domain.com-2020.rsa;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    # Special root site case. prevent "try_files $uri/" + "index" from skipping the cache
    # by accessing /index.php directly
    location =/ {
        recursive_error_pages on;
        error_page 405 = @sfc;
        return 405;
    }

    location @t3frontend {
        # Using try_files for ease of configuration demonstration here,
        # you can also fastcgi_pass directly to php here
        try_files $uri /index.php$is_args$args;
    }

    location @sfc {
        # Perform an internal redirect to TYPO3 if any of the required
        # conditions for StaticFileCache don't match
        error_page 405 = @t3frontend;

        # Query String needs to be empty
        if ($args != '') {
            return 405;
        }

        # We can't serve static files for logged-in BE/FE users
        if ($cookie_staticfilecache = 'fe_typo_user_logged_in') {
            return 405;
        }
        if ($cookie_be_typo_user != '') {
            return 405;
        }

        # Ensure we redirect to TYPO3 for non GET/HEAD requests
        if ($request_method !~ ^(GET|HEAD)$ ) {
            return 405;
        }

        charset utf-8;
        try_files /typo3temp/tx_staticfilecache/${scheme}/${host}/${server_port}${uri}/index.html
        /typo3temp/tx_staticfilecache/${scheme}/${host}/${server_port}${uri}
        =405;
    }

    location /typo3temp/tx_staticfilecache {
            deny all;
    }

    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    }

    location ~ /\.ht {
            deny all;
    }

    # Prevent clients from accessing hidden files (starting with a dot)
    # This is particularly important if you store .htpasswd files in the site hierarchy
    # Access to `/.well-known/` is allowed.
    # https://www.mnot.net/blog/2010/04/07/well-known
    # https://tools.ietf.org/html/rfc5785
    location ~* /\.(?!well-known\/) {
        deny all;
    }

    # Prevent clients from accessing to backup/config/source files
        location ~* (?:\.(?:bak|conf|dist|fla|in[ci]|log|psd|sh|sql|sw[op])|~)$ {
        deny all;
    }

    # TYPO3 - Block access to composer files
    location ~* composer\.(?:json|lock) {
        deny all;
    }

    # TYPO3 - Block access to flexform files
    location ~* flexform[^.]*\.xml {
        deny all;
    }

    # TYPO3 - Block access to language files
    location ~* locallang[^.]*\.(?:xml|xlf)$ {
        deny all;
    }

    # TYPO3 - Block access to static typoscript files
    location ~* ext_conf_template\.txt|ext_typoscript_constants\.(?:txt|typoscript)|ext_typoscript_setup\.(?:txt|typoscript) {
        deny all;
    }

    # TYPO3 - Block access to miscellaneous protected files
    location ~* /.*\.(?:bak|co?nf|cfg|ya?ml|ts|typoscript|dist|fla|in[ci]|log|sh|sql)$ {
        deny all;
    }

    # TYPO3 - Block access to recycler and temporary directories
    location ~ _(?:recycler|temp)_/ {
        deny all;
    }

    # TYPO3 - Block access to configuration files stored in fileadmin
    location ~ fileadmin/(?:templates)/.*\.(?:txt|ts|typoscript)$ {
        deny all;
    }

    # TYPO3 - Block access to libaries, source and temporary compiled data
    location ~ ^(?:vendor|typo3_src|typo3temp/var) {
        deny all;
    }

    # TYPO3 - Block access to protected extension directories
    location ~ (?:typo3conf/ext|typo3/sysext|typo3/ext)/[^/]+/(?:Configuration|Resources/Private|Tests?|Documentation|docs?)/ {
        deny all;
    }
}
server {
    if ($host = domain.com) {
        return 301 https://$host$request_uri;
    }


        listen 80;
        server_name domain.com;
    return 404; 
}

这是realurl的配置:

模板分析没有显示任何错误。这是realurl:

的模板分析

更新 2

我在这个问题上更进了一步。我已经阅读了与我的问题类似的错误报告 https://github.com/dmitryd/typo3-realurl/issues/333。我尝试将 config.linkVars 值从 L 切换为 L(0,1)。这有助于 URL 问题。但现在它总是切换回德语。

config.linkVars中设置L,它在url中添加了语言,如果不是德语:

domain.com/en/prices

使用新值 L(0,1) 它删除了 URL

中的语言

domain.com/prices

所以它始终显示德文版页面。我什至尝试将值设置为 L(0,2),因为德语、英语和法语是集成的(1=英语,2=法语),但在这种情况下它无济于事。由于 URL.

中缺少语言代码,它总是切换回德语

好的。现在我找到了解决方案。 正如我在评论中所写的那样,它是配置设置:

config.linkVars

最初设置为

config.linkVars = L

在我发现这个错误报告后

https://github.com/dmitryd/typo3-realurl/issues/333

我发现出于安全原因,我需要限制 L 值。 在我们的案例中,德语为 0,英语为 1,法语为 2:

config.linkVars = L(0-2)

然后一切正常。