Ale*_*lex 7 .htaccess angular aws-amplify
我在 AWS Amplify 上提供 Angular SPA,我想重新创建与我在.htaccess文件中相同的重写规则:
RewriteEngine On
# Remove trailing /
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Rewrite spiders to static html
RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot|msnbot|yahoo|Baidu|aolbuild|facebookexternalhit|iaskspider|DuckDuckBot|Applebot|Almaden|iarchive|archive.org_bot) [NC]
RewriteCond %{DOCUMENT_ROOT}/static%{REQUEST_URI}.html -f
RewriteRule ^(.*)$ /static/$1.html [L]
# Rewrite spiders to static index.html
RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot|msnbot|yahoo|Baidu|aolbuild|facebookexternalhit|iaskspider|DuckDuckBot|Applebot|Almaden|iarchive|archive.org_bot) [NC]
RewriteCond %{REQUEST_URI} "^/$"
RewriteRule ^ /static/index.html [L]
# If an existing asset or directory is requested, serve it
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
# If the requested resource doesn't exist, use the Angular app entry point
RewriteRule ^ /index.html
Run Code Online (Sandbox Code Playgroud)
AWS Amplify 似乎不支持附加的 .htaccess 文件 (?),但允许您在控制台中配置重写和重定向。它要求这种格式:
[
{
"condition": "",
"source": "",
"status": "200",
"target": ""
}
]
Run Code Online (Sandbox Code Playgroud)
如果我尝试设置"condition"为"%{HTTP_USER_AGENT} (googlebot|bingbot|msnbot|yahoo|Baidu|aolbuild|facebookexternalhit|iaskspider|DuckDuckBot|Applebot|Almaden|iarchive|archive.org_bot) [NC]"并保存,则该值设置为null.
关于如何格式化这个的任何想法?
| 归档时间: |
|
| 查看次数: |
173 次 |
| 最近记录: |