简单的apache mod_rewrite只是不起作用

时间:2017-11-19 03:34:30

标签: node.js apache mod-rewrite

我想要的很简单,但它只是不起作用。

首先,应用程序在Node.js上运行,即localhost:8080 我使用Apache mod_rewrite将请求路由到Node.js,就像这个

<VirtualHost *:443>
    RequestHeader set X-Forwarded-Proto "https"
    ProxyPreserveHost On
    ServerName shopecific.com
    RewriteEngine On
    RewriteRule /(.*)           http://localhost:8080/$1 [P,L]
    ...
</VirtaulHost>

完美无缺。然后我想将一个请求重定向到静态页面,该页面从https://shopecific.com/amzvarhttps://shopecific.com/amzvar.html

但是我尝试了以下重写规则,但这些规则都没有:

# RewriteRule ^/amzvar$, /amzvar.html [R,L]
# RewriteRule ^/amzvar$, https://shopecific.com/amzvar.html [R,L]
# RedirectMatch 301 ^/amzvar$ https://shopecific.com/amzvar.html

不知何故,这些规则被忽略了,我总是找到未找到的页面。请注意,“amzvar”不是Node.js上的已定义路由。我理解通过routers.js中的以下规则,它可以被重定向到“找不到”。

<Route path="*" component={NotFound} status={404} />

但是,首先应该匹配Apache规则,对吗?

我在这里缺少什么?

1 个答案:

答案 0 :(得分:0)

看起来这与Service Worker有关。不知何故,React-Router V3和Service Worker不能一起处理未定义的路由器(即,即使在Apache配置中,它也将重定向到默认路由(),无论其他规则如何。

相关问题