简体   繁体   English

Wordpress和angular2网址路由不起作用

[英]Wordpress and angular2 url routes not working

I am working on an angular2 application which is placed along with wordpress site. 我正在开发一个与wordpress网站一起放置的angular2应用程序。 Following is the directory structure: 以下是目录结构:

/var/www/html
 app/ (angular2 app is placed under this folder)
 wp-includes/
 wp-content/
 ...

htaccess file is placed under the html folder for wordpress url rewriting and another htaccess is placed under app folder for angular2 urls. htaccess文件放在html文件夹下,用于wordpress url重写,另一个htaccess放在app2文件夹下,用于angular2网址。 I have updated htaccess file of wordpress to ignore urls under app folder but now urls of wordpress are not working and apache 404 is coming. 我更新了wordpress的htaccess文件以忽略app文件夹下的url但是现在wordpress的url不起作用而apache 404即将到来。 Following is my htaccess file for wordpress: 以下是我的wordpress的htaccess文件:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} "/app/"
RewriteRule . index.php [L]
</IfModule>
 RewriteCond %{REQUEST_URI} "/app/" 

That directive doesn't "ignore urls under app folder" - it does the opposite and only routes the WordPress URLs when accessing a URL that contains /app/ (anywhere in the URL). 该指令不“忽略app文件夹下的URL” - 它执行相反的操作并且仅在访问包含/app/ (URL中的任何位置)的URL时路由WordPress URL。 To exclude that subdirectory, change the directive to: 要排除该子目录,请将指令更改为:

RewriteCond %{REQUEST_URI} !^/app/

To match URLs that do not start with /app/ (note the ! prefix, that negates the regex). 要匹配不以/app/ 开头的 URL(请注意!前缀,否定正则表达式)。

However, if you already have a .htaccess file in the /app subdirectory that contains mod_rewrite directives then you shouldn't have to do this. 但是,如果/app子目录中已包含一个包含mod_rewrite指令的.htaccess文件,则不必执行此操作。 The mod_rewrite directives in the subdirectory will completely override the mod_rewrite directives in the parent .htaccess file (since mod_rewrite directives are not inherited by default). 子目录中的mod_rewrite指令将完全覆盖父.htaccess文件中的mod_rewrite指令(因为默认情况下不会继承mod_rewrite指令)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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