【问题标题】:Extension realurl - display of SQL query parts in URL扩展 realurl - 在 URL 中显示 SQL 查询部分
【发布时间】:2020-07-28 06:48:36
【问题描述】:

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

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

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

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 这样的演讲网址。那么为什么它在第一次加载时工作,但后来不再工作?

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

什么会导致这种行为?

更新

我实际上看到,该网站的英文版运行良好。所以在这里,链接显示正确: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 中缺少语言代码,它总是切换回德语。

【问题讨论】:

  • 首先我会检查为什么在语言参数(&L=1)之后添加了一部分sql查询。也许你的打字有问题。也许那时链接工作正常。
  • @RenéPflamm,感谢您的回答。你能告诉我在哪里可以检查这个吗?
  • 查看模板下的打字稿对象浏览器,如果显示常量则切换到打字稿,从查询中搜索name_const 或其他内容。也许模板分析(也在模板下)显示了一些失败。替代显示在您在打字稿中定义 L 参数的位置,并查看是否缺少一些大括号。
  • 我已经添加了来自realurl 的配置。在typoscript对象浏览器的常量中没有来自realurl的条目。
  • @RenéPflamm 我向前迈了一步。我发现了这个错误报告,它解释了我的问题。 github.com/dmitryd/typo3-realurl/issues/333 我已将 config.linkVars 值从 L 更改为 L(0,1),这有助于解决 URL 问题,但现在它总是切换回德语。知道如何避免这种情况吗?

标签: nginx typo3 typo3-8.x realurl


【解决方案1】:

好的。现在我找到了解决方案。 正如我在 cmets 中所写,这是配置设置:

config.linkVars

最初设置为

config.linkVars = L

在我发现这个错误报告之后

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

我看到出于安全原因需要限制L-值。 在我们的例子中,0 代表德语,1 代表英语,2 代表法语:

config.linkVars = L(0-2)

然后一切正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多