WordPress / wporg-documentation-2022

15 stars 6 forks source link

Site & content redirects #21

Closed ryelle closed 1 year ago

ryelle commented 1 year ago

@estelaris Do you have a list of the redirects you expect to need?

I know you want to update the URL from .org/support/ to .org/documentation.

I see some articles in this spreadsheet are marked "301", since they're moving from support to devhub. Is that list correct?

Also in the sheet, I see articles are being renamed - will the slugs change? For example, I see you want to rename the "Using Themes" page to "Working with Themes", should the URL also change from https://wordpress.org/support/article/using-themes/?


Right now, we're considering moving all the content over to https://wordpress.org/documentation-test/, where we can set up the new templates over the current content. This will split the helphub content from the support forums site.

We can edit the content on this site, set up the topic landing pages, etc.

When we want to launch, we can rename that site to https://wordpress.org/documentation/ and set up some blanket redirects to cover /support/article/*, /support/category/*, /support/wordpress-version/*.

If we need other specific redirects, to cover paths that changed or no longer exist, we'll need to set that up somewhere (code? plugin?)

cc @tellyworth

estelaris commented 1 year ago

Use the list on these issues:

ryelle commented 1 year ago

Content redirects were added in https://github.com/WordPress/wporg-documentation-2022/commit/564bb2e538e8ef8d7a4de993560d8f248b20a6b7 (and fixed in https://github.com/WordPress/wporg-documentation-2022/commit/b009513b7c65ed3897ecb65e2fd6263141963769).

Redirects from support will be added to site-support.php

@@ -7,6 +7,9 @@

 namespace WordPressdotorg\Support_2022\MU_Plugin;

+add_action( 'init', __NAMESPACE__ . '\add_rewrite_rules' );
+add_action( 'template_redirect', __NAMESPACE__ . '\redirect_to_documentation', 9 ); // Before redirect_canonical();
+
 /**
  * Add rewrite rules.
  *
@@ -25,4 +28,122 @@
        'top'
    );
 }
-add_action( 'init', __NAMESPACE__ . '\add_rewrite_rules' );
+
+/**
+ * Redirect the documentation pages to /documentation/.
+ */
+function redirect_to_documentation() {
+   // Don't redirect if the URL has a querystring.
+   if ( str_contains( $_SERVER['REQUEST_URI'], '?' ) ) {
+       return;
+   }
+
+   $request_uri = $_SERVER['REQUEST_URI'] ?? '/support/';
+
+   // Simple homepage redirect.
+   if ( '/support/' === $request_uri ) {
+       do_redirect_and_exit( '/documentation/' );
+   }
+
+   // Redirect single URLs.
+   $path_redirects = [
+       // Renamed categories.
+       '/support/category/basic-administration/' => '/documentation/category/dashboard/',
+       '/support/category/troubleshooting/'      => '/documentation/category/faqs/',
+       '/support/category/installation/'         => '/documentation/category/installation/',
+       '/support/category/maintenance/'          => '/documentation/category/maintenance/',
+       '/support/category/security/'             => '/documentation/category/security/',
+       '/support/category/getting-started/'      => '/documentation/category/where-to-start/',
+
+       // Top-level category landing pages.
+       '/support/category/customizing/' => '/documentation/customization/',
+       '/support/category/basic-usage/' => '/documentation/support-guides/',
+   ];
+   foreach ( $path_redirects as $old_path => $new_path ) {
+       if ( $request_uri === $old_path ) {
+           do_redirect_and_exit( $new_path );
+       }
+   }
+
+   // These pages have been removed, and will be on dev.w.org eventually.
+   // For now, they're simply redirected to developer.wordpress.org.
+   $devhub_redirects = [
+       '/support/category/advanced-topics/',
+       '/support/article/before-you-install/',
+       '/support/article/creating-database-for-wordpress/',
+       '/support/article/installing-wordpress-on-your-own-computer/',
+       '/support/article/running-a-development-copy-of-wordpress/',
+       '/support/article/how-to-install-wordpress/',
+       '/support/article/installing-wordpress-in-your-language/',
+       '/support/article/installing-multiple-blogs/',
+       '/support/article/using-your-browser-to-diagnose-javascript-errors/',
+       '/support/article/debugging-a-wordpress-network/',
+       '/support/article/debugging-in-wordpress/',
+       '/support/article/test-driving-wordpress/',
+       '/support/article/network-admin/',
+       '/support/article/network-admin-sites-screen/',
+       '/support/article/network-admin-updates-screen/',
+       '/support/article/multisite-network-administration/',
+       '/support/article/create-a-network/',
+       '/support/article/wordpress-multisite-domain-mapping/',
+       '/support/article/before-you-create-a-network/',
+       '/support/article/optimization-caching/',
+       '/support/article/must-use-plugins/',
+       '/support/article/restoring-your-database-from-backup/',
+       '/support/article/wordpress-backups/',
+       '/support/article/backing-up-your-database/',
+       '/support/article/backing-up-your-wordpress-files/',
+       '/support/article/brute-force-attacks/',
+       '/support/article/hardening-wordpress/',
+       '/support/article/administration-over-ssl/',
+       '/support/article/https-for-wordpress/',
+       '/support/article/two-step-authentication/',
+       '/support/article/emptying-a-database-table/',
+       '/support/article/changing-file-permissions/',
+       '/support/article/finding-server-info/',
+       '/support/article/nginx/',
+       '/support/article/giving-wordpress-its-own-directory/',
+       '/support/article/ftp-clients/',
+       '/support/article/using-filezilla/',
+       '/support/article/changing-the-site-url/',
+       '/support/article/moving-wordpress/',
+       '/support/article/phpmyadmin/',
+       '/support/article/configuring-automatic-background-updates/',
+       '/support/article/upgrading-wordpress-extended-instructions/',
+       '/support/article/cookies/',
+       '/support/article/css/',
+       '/support/article/editing-files/',
+       '/support/article/multilingual-wordpress/',
+       '/support/article/update-services/',
+       '/support/article/editing-wp-config-php/',
+   ];
+   foreach ( $devhub_redirects as $old_path ) {
+       if ( $request_uri === $old_path ) {
+           // Use a 302 redirect and don't cache, this will be updated when the real articles are published.
+           wp_safe_redirect( 'https://developer.wordpress.org', 302 );
+           exit;
+       }
+   }
+
+   // Redirect all URLs starting with these…
+   $section_redirects = [
+       // Main content: articles & version docs, categories.
+       '/support/article/'           => '/documentation/article/',
+       '/support/wordpress-version/' => '/documentation/wordpress-version/',
+       '/support/category/'          => '/documentation/category/',
+   ];
+   foreach ( $section_redirects as $old_path => $new_path ) {
+       if ( str_starts_with( $request_uri, $old_path ) ) {
+           $redirect_path = str_replace( $old_path, $new_path, $request_uri );
+           do_redirect_and_exit( $redirect_path );
+       }
+   }
+}
+
+function do_redirect_and_exit( $location ) {
+   header_remove( 'expires' );
+   header_remove( 'cache-control' );
+
+   wp_safe_redirect( $location, 301 );
+   exit;
+}
ryelle commented 1 year ago

This was committed and deployed with [19868-dotorg].