简体   繁体   中英

Conversion of a pagetree within a TYPO3 multitree to SSL

In a mutlitree TYPO3 project, only one tree should be migrated to SSL. For this I would have to set the url_scheme within this tree for all pages to "https". However, since there are many sides, this would not be efficient to solve it manually.

Example 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)

The following SQL command can be used to set all pages to the desired value:

UPDATE pages SET url_scheme = 2

But i need a SQL update command for my single pagetree (A) only. Does anyone have an idea how the SQL command would look for it?

Inspiration to this was here: https://www.wacon.de/typo3-know-how/umstellung-von-http-auf-https-mit-typo3.html

If you have different URIs for each PageTree you can try to use an .htaccess RewriteCond to redirect directly to your SSL version:

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

Otherwise you have to determine which subpages belongs to the "Pagetree A". A simple SQL query could be:

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

if you have more than one treelevel it would be complicated. Then you must find the uids of the page tree and than update these pages also, something like this whould update your second pagetree:

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

You could use the cf_cache_rootline table to retrieve a list of recursive sub-pages. That's kind of ugly to do in SQL, as you need to manually parse the serialized array, but it works:

Use the following query to check whether you get some sensible data:

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';

Then the update would be (given PageTree A has 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');

And a site note, to enable url_scheme=2 permanently for that subtree, you can add a Page TSConfig, to set this for new pages:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM