我在Apache中部署了一个网站:http://mysite.test。我需要在http://mysite.test/blog配置wordpress。 我尝试使用别名配置它,但它会继续重定向到主站点的默认页面。主站点有Angular 1.5,配置了漂亮的URL。这是apache配置:
<VirtualHost *:80>
DocumentRoot "/Users/iulia/git/mysite/app/src"
ServerName mysite.test
ErrorLog /Users/iulia/tmp/error.log
CustomLog /Users/iulia/tmp/access.log combined
Alias /blog "/Users/iulia/git/mysite/blog"
<Directory "/Users/iulia/git/mysite/blog">
Options FollowSymLinks
allow from all
AllowOverride All
Require all granted
</Directory>
<Directory "/Users/iulia/git/mysite/app/src">
AllowOverride All
Require all granted
</Directory>
# Angular HTML5 routes
RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
# If the requested pattern is file and file doesn't exist, send 404
RewriteCond %{REQUEST_URI} ^(\/[a-z_\-\s0-9\.]+)+\.[a-zA-Z]{2,4}$
RewriteRule ^ - [L,R=404]
# otherwise use history router
RewriteRule ^ /index.html
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip
答案 0 :(得分:0)
使用根文件夹删除目录并添加了RewriteCond%{REQUEST_URI}时有效!^ / blog /(.*):
<VirtualHost *:80>
DocumentRoot "/Users/iulia/git/mysite/app/src"
ServerName mysite.test
ErrorLog /Users/iulia/tmp/feUserError.log
CustomLog /Users/iulia/tmp/feUserAccess.log combined
Alias /blog "/Users/iulia/git/mysite/blog"
<Directory "/Users/iulia/git/mysite/blog">
Options FollowSymLinks
allow from all
AllowOverride All
Require all granted
</Directory>
# <Directory "/Users/iulia/git/mysite/app/src">
# AllowOverride All
# Require all granted
# </Directory>
# Angular HTML5 routes
RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{REQUEST_URI} !^/blog/(.*)
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
# If the requested pattern is file and file doesn't exist, send 404
RewriteCond %{REQUEST_URI} !^/blog/(.*)
RewriteCond %{REQUEST_URI} ^(\/[a-z_\-\s0-9\.]+)+\.[a-zA-Z]{2,4}$
RewriteRule ^ - [L,R=404]
# otherwise use history router
RewriteCond %{REQUEST_URI} !^/blog/(.*)
RewriteRule ^ /index.html
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip