2016-12-06 22 views
0

在TYPO3项目中,只有一棵树应该迁移到SSL。为此,我必须将此树中的所有页面设为url_scheme以“https”。但是,由于存在很多方面,所以手动解决这个问题效率不高。将TYPO3多层树中的页树转换为SSL

例Pagetree

+-- TYPO3 6.2 LTS 
+--+-- Pagetree A (DE)    // need only this pagetree converted to SSL 
+--+--+-- Pagetree A Subpage 1 (DE) 
+--+--+-- Pagetree A Subpage 2 (DE) 
+--+--+-- Pagetree A Subpage 3 (DE) 
+--+-- Pagetree B (EN) 
+--+--+-- Pagetree B Subpage 1 (EN) 
+--+--+-- Pagetree B Subpage 2 (EN) 
+--+--+-- Pagetree B Subpage 3 (EN) 
+--+-- Pagetree C (FR) 
+--+--+-- Pagetree C Subpage 1 (FR) 
+--+--+-- Pagetree C Subpage 2 (FR) 
+--+--+-- Pagetree C Subpage 3 (FR) 
+--+-- Pagetree D (COM) 
+--+--+-- Pagetree D Subpage 1 (COM) 
+--+--+-- Pagetree D Subpage 2 (COM) 
+--+--+-- Pagetree D Subpage 3 (COM) 

以下SQL命令可以被用来设置所有网页,以所需的值:

UPDATE pages SET url_scheme = 2 

但我需要一个SQL更新命令用于我的单pagetree( A)只。 有没有人有一个想法如何SQL命令会寻找它?

启示,这是在这里:https://www.wacon.de/typo3-know-how/umstellung-von-http-auf-https-mit-typo3.html

回答

0

您可以使用cf_cache_rootline表检索的递归子页面的列表。这是一种丑陋的SQL做的,因为你需要手工解析序列化的数组,但它的工作原理:

使用下面的查询,以检查是否获得一些敏感数据:

set @pid = 40; select REPLACE(identifier, '__0_0_0', '') as ids from cf_cache_rootline where content like CONCAT('%"pid";s:', LENGTH(@pid), ':"', @pid, '"%') and identifier like '%\_\_0\_0\_0'; 

然后,更新将(给PageTree A已经UID = 40):

SET @pid = 40; 
UPDATE pages SET url_scheme = 2 WHERE uid = @pid OR uid IN (select REPLACE(identifier, '__0_0_0', '') FROM cf_cache_rootline WHERE content LIKE CONCAT('%"pid";s:', LENGTH(@pid), ':"', @pid, '"%') AND identifier LIKE '%\_\_0\_0\_0'); 

和站点音符,使url_scheme=2永久为子树,你可以添加一个选项Page TSconfig,设置此新页面:

[PIDinRootline = 40] 
TCAdefaults.pages.url_scheme = 2 
[global] 
1

如果你必须为每个PageTree不同的URI,你可以尝试使用一个.htaccess的RewriteCond直接重定向到您的SSL版本:

RewriteCond %{HTTPS} off 
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.tld$ 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

否则,你有以确定哪些子页面属于“Pagetree A”。一个简单的SQL查询可能是:

UPDATE pages SET url_scheme = 2 WHERE pid = UID_OF_PAGETREE_A OR uid = UID_OF_PAGETREE_A 

如果你有多个treelevel,它会很复杂。然后,你必须找到页面树的UID和比也更新这些网页,这样的更新对子级你的第二个pagetree:

UPDATE pages SET url_scheme = 2 WHERE pid IN (SELECT uid FROM pages WHERE pid = UID_OF_PAGETREE_A) 
+0

您不应该仅依赖于http-> https重定向。链接到http://是不安全的,而不是正确链接到https://的替代方法。 –

+0

如果您没有正确使用“url_scheme”并配置typo3,则内部链接由活动方案完成。所以不是每一个页面都访问重定向。只有第一次访问。 –

+0

谢谢勒内,你的解决方案是一个很好的选择,但本杰明的方式是我需要的100%。谢谢。 – Eckonator