TYPO3 6.2:禁用页面时如何实现301重定向至首页?
Hey there! Let's sort out this TYPO3 6.2 issue you're dealing with—getting that hidden (disabled) page to return a 301 redirect to your homepage instead of a 404 is totally doable, and it’ll let you keep developing while fixing the Google indexing problem. Here are the most reliable methods tailored to your version:
Method 1: Global TypoScript (Affects All Disabled Pages)
If you want every disabled page to redirect to the homepage, use your root template’s TypoScript setup:
- Head to the Template module in the TYPO3 backend.
- Select your root template and edit its Setup section.
- Paste this code:
# Trigger redirect only for hidden pages [page["hidden"] == 1] # Send 301 permanent redirect header config.additionalHeaders = HTTP/1.1 301 Moved Permanently config.additionalHeaders.location = / # Ensure TYPO3 doesn’t render any extra content config.sendCacheHeaders = 1 page = PAGE page.typeNum = 0 page.config.disableAllHeaderCode = 1 page.body > [end]
- Clear TYPO3’s system cache (you can do this from the top toolbar’s cache icon) to apply the changes.
Method 2: Page-Specific TSconfig (Only Target Your Problem Page)
If you only need this redirect for that one special page (and leave other disabled pages as 404), use page-level TSconfig:
- Go to the disabled page’s properties in the Page module.
- Switch to the Resources tab, then find the Page TSconfig field.
- Replace
YOUR_PAGE_IDwith the ID of your disabled page and add this code:
[globalVar = TSFE:id = YOUR_PAGE_ID] config.additionalHeaders = HTTP/1.1 301 Moved Permanently config.additionalHeaders.location = / config.sendCacheHeaders = 1 page = PAGE page.typeNum = 0 page.config.disableAllHeaderCode = 1 page.body > [end]
- Again, clear the cache to make sure the change takes effect.
Bonus: Clean Up Google’s Index
Once the redirect is working, head over to Google Search Console (if you have it set up) and submit a URL removal request for the indexed disabled page. This will speed up Google’s process of removing it from search results.
Alternative: .htaccess Redirect
If you prefer server-level changes, you can add this line to your site’s .htaccess file (replace /your-disabled-page-url with the actual URL of the page):
Redirect 301 /your-disabled-page-url /
Just note that this method won’t tie into TYPO3’s page hidden status—you’ll need to update the .htaccess if the page URL changes later.
内容的提问来源于stack exchange,提问作者Paolito75

