将TYPO3多个树中的pagetree转换为SSL

时间:2016-12-06 13:58:12

标签: sql ssl typo3 typo3-6.2.x

在mutlitree TYPO3项目中,只应将一棵树迁移到SSL。为此,我必须在此树中将 url_scheme 设置为" https"的所有页面。但是,由于存在许多方面,因此手动解决这种方法效率不高。

示例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

但是我只需要单个pagetree(A)的SQL更新命令。 有没有人知道SQL命令将如何寻找它?

对此的启示是:https://www.wacon.de/typo3-know-how/umstellung-von-http-auf-https-mit-typo3.html

2 个答案:

答案 0 :(得分: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

如果你有多个树级别,那将会很复杂。然后你必须找到页面树的uid,并且还要更新这些页面,这样可以更新你的第二个pagetree:

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

答案 1 :(得分: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]