安装wordpress与angular

问题描述 投票:1回答:1

我有一个使用apache服务器运行的角度项目。 apache文件根目录是/var/www/angular/dist/my-project。在这个文件夹中,我创建了一个符号链接,它引用了我安装了wordpress的/var/www/wordpress目录。在“000-default.conf”文件中我有

RewriteCond %{REQUEST_URI} !^/index.html$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(json|css|gif|ico|jpg|js|png|swf|txt|svg|woff|ttf|eot)$
#added this line to make the wordpress work
RewriteCond %{REQUEST_URI} !^/blog/
RewriteRule . /index.html [L]

但上面的代码不起作用。我总是得到index.html的角项目

但是,如果我去domain.com/blog它再次返回index.html。但是如果我键入任何随机网址,则此index.html页面不会显示404。

angular wordpress apache .htaccess
1个回答
1
投票

虽然这可能无法回答您的直接问题,但也许我可以提供替代解决方案。

使用Xo for Angular,您可以在现有的Angular App中整合由WordPress提供支持的博客,并将其作为集成应用程序提供。

https://wordpress.org/plugins/xo-for-angular/

Xo for Angular可以帮助您编写重写,以便通过WordPress加载Angular主题或直接为所有前端请求加载。

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^xo-api/(.*)$ /index.php [NC,L]
    RewriteRule ^wp-json/(.*)$ /index.php [NC,L]
    RewriteRule ^/?$ /wp-content/themes/angular-xo-material/dist/index.html [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /wp-content/themes/angular-xo-material/dist/index.html [L]
</IfModule>

文档(正在进行中):https://angularxo.io/

插件github:https://github.com/WarriorRocker/angular-xo-core

示例主题:https://github.com/WarriorRocker/angular-xo-material

应该可以将现有的Angular应用程序复制到新主题,并让Xo for Angular插件加载并将前端请求定向到Angular索引。然后,您可以使用Xo API检索WordPress中的页面和帖子。如果您决定让Xo和WordPress控制,则Ango的Xo也可以生成动态页面路由。

完全披露我是上述插件和主题的作者。

如果您认为这对您有用,请告诉我,谢谢!

© www.soinside.com 2019 - 2024. All rights reserved.