.htaccess问题在angular7应用程序和wordpress应用程序中



我有angular7应用程序和Wordpress应用程序。Angular7应用程序在根文件夹中运行。Wordpress在"博客"(子文件夹(中运行。我在angular.json中添加了"博客"作为静态文件夹。我的angular应用程序运行成功。但我的Wordpress没有运行。

在这里,我附上了两者的.htaccess文件。请帮我解决这个

角度构建:https://example.comWordpress:https://example.com/blog

.htaccess for Angular应用程序

<IfModule mod_rewrite.c>
RewriteEngine on
# RewriteBase /
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTP_HOST} ^(.*)$  [NC]
RewriteRule (.*) https://www.%1/$1 [R=301,L]
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html
# to allow html5 state links
RewriteRule ^ index.html [L]    
</IfModule>

.htaccess for wordpress

# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress

我也遇到过同样的问题。如果我理解正确,你的文件夹结构如下:

|– www/           // your root directory
|   |– blog/      // your blog sub-directory

当您在博客子目录中时,您必须将其视为.htaccess中的当前目录。/blog/的规则是错误的,例如:

RewriteRule. /blog/index.php [L]

你可以试试:

www/blog/.htaccess

.htaccess:

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

最新更新