You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ddev环境下TYPO3项目报500错误,Trusted Hosts Pattern匹配异常

Solution for TYPO3 500 Error with Trusted Hosts Pattern in DDEV v0.18.0

Let's work through why your .* trusted hosts pattern isn't behaving as expected and fix this issue step by step:

1. Confirm AdditionalConfiguration.php is in the Right Spot & Loaded

First, double-check your AdditionalConfiguration.php is placed in the correct directory: it needs to live inside the typo3conf/ folder at your project root (in the DDEV container, that translates to /var/www/html/typo3conf/AdditionalConfiguration.php).

To verify TYPO3 is actually reading this file, add a quick test line at the top:

die('AdditionalConfiguration.php loaded successfully!');

Refresh your site — if you see this message, the file is being processed; if not, you’ve put it in the wrong location.

2. Flush TYPO3's Configuration Cache

TYPO3 caches configuration files aggressively, so even if you updated the trusted hosts pattern, old cached settings might still be active.

Run this command in your terminal to clear the cache manually:

ddev exec rm -rf typo3temp/var/cache/

If you’re using TYPO3 9 or later, you can use the official CLI command instead:

ddev exec typo3cms cache:flush

3. Adjust the Trusted Hosts Pattern (Even if .* "Should" Work)

While .* theoretically matches any host header, there might be edge cases with how TYPO3’s preg_match handles the pattern — especially since your host header includes a port (typo3-master.ddev.local:8000).

Try replacing your current pattern with one explicitly accounting for optional ports:

$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = 'typo3-master\.ddev\.local(:\d+)?';

This matches your base host with an optional port suffix, so it works whether you use port 8000 or switch to a default port later.

If you want to keep a broad pattern, try adding regex anchors to ensure full string matching:

$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = '^.*$';

4. Restart DDEV Services

Older DDEV versions (like v0.18.0) sometimes need a full restart to pick up configuration changes. Run this to refresh your environment:

ddev restart

5. Check for Conflicting Settings

Open typo3conf/LocalConfiguration.php and search for trustedHostsPattern. If it’s defined there, make sure your AdditionalConfiguration.php setting is overriding it (since AdditionalConfiguration.php loads after LocalConfiguration.php, it should take priority — but it’s worth verifying no typos or syntax errors are preventing this).


内容的提问来源于stack exchange,提问作者rfay

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 07:08:43