So erstellen Sie ein Wordpress in einem Unterverzeichnis der Next JS-Anwendung
P粉006540600
P粉006540600 2023-08-29 14:53:13
0
1
382

Liebe Community, Hallo,

Meine Webanwendung verwendet next JS unter dem Domainnamen domain.com

Jetzt möchte ich unter example.com/community

einen WordPress-Blog (wordblog.com/community) erstellen.

Mit Next JS Rewrites habe ich Folgendes zu meiner nächsten Konfiguration hinzugefügt:

async rewrites() { zurückkehren { zurückgreifen: [ { Quelle: "/community/:path*", Ziel: `https://wordblog.com/community/:path*`, }, ], } },

In meinem WordPress-Installationsordner.

1- Fügen Sie es zu .htacces

hinzu.
  Header-Set Access-Control-Allow-Origin "*"  

2 – Fügen Sie dies zu wp-config.php hinzu:

define('WP_SITEURL', 'https://wordblog.com/community'); define('WP_HOME', 'https://example.com/community'); define('COOKIE_DOMAIN', '.example.com');

3-Dieses wp-content/themes/your-theme/functions.php

hinzugefügt
remove_filter('template_redirect','redirect_canonical'); add_filter('rest_url', 'serve_rest_url_on_wp_subdomain'); Funktion dienen_rest_url_on_wp_subdomain ($url) { return str_replace('https://example.com/community', 'https://wordblog.com/community', $url); }

Aber wenn ich domain.com/community besuche, werde ich zu wordblog.com/community weitergeleitet.

Außerdem werden einige Seiten von wordblog.com/community unter wordblog.com/community/pageX statt unter domain.com/community/pageX gerendert

P粉006540600
P粉006540600

Antworte allen (1)
P粉154798196

您也许可以在 apache 设置中使用 Alias 指令来解决此问题:https://httpd.apache.org/docs/2.0/mod/mod_alias.html#alias

这意味着您必须删除 nextJS 中的重定向。 Apache 会知道从您的 WordPress 安装中提供服务 /community。

    Neueste Downloads
    Mehr>
    Web-Effekte
    Quellcode der Website
    Website-Materialien
    Frontend-Vorlage
    Über uns Haftungsausschluss Sitemap
    Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!