-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Site & content redirects #21
Labels
[Component] Backend
Anything wp-admin or PHP-related
Milestone
Comments
Use the list on these issues: |
Content redirects were added in 564bb2e (and fixed in b009513). Redirects from support will be added to @@ -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;
+} |
This was committed and deployed with [19868-dotorg]. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@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
The text was updated successfully, but these errors were encountered: