grunt-html-snapshot を使用して、Angular Web アプリケーションの静的スナップショットを作成しています。サイトは、次の階層を使用している CMS によって駆動されます
/ (page)
/somecateogry (page)
/somecategory/somepage (page)
/somecategory/anotherpage (page)
問題は、 grunt がページのスナップショットをアンダースコア付きのカテゴリに保存することです (たとえば、snapshot____somecategory_somepage.html )。
提供された書き換えルールを使用して、カテゴリ ページのスナップショットdomain.com/?_escaped_fragment_=/categoryに到達できます。これは/snapshots/snapshot____category.htmlに書き換えられます。
ただし、問題があるサブページは/snapshots/snapshot____category/subpage.htmlに書き換えられます。
正直なところ、私は mod_rewrite を実際に使用した経験がありません (この記事のおかげで、現在の状態に到達できました)。ただし、どうにかして QueryString を取得し、すべてのスラッシュ (/) をアンダースコアに書き換える必要があるという考えが正しいことを願っています。また、サブカテゴリを追加するとどうなるか少し心配ですが、それは今のところ重要ではありません.
<VirtualHost *:80>
DocumentRoot "/var/node-www/hornet"
# Snapshot directory (Crawling directory)
RewriteLog "/var/node-www/hornet/rw-log"
RewriteLoglevel 4
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/?(.*)$
RewriteRule ^(.*)$ /snapshots/snapshot____%1.html? [NC,L]
ProxyPreserveHost On
ProxyRequests Off
ServerName local.hornet
ServerAlias local.hornet
# Send to Tomcat
ProxyPass /rest/ http://localhost:8080/Hornet/rest/
ProxyPassReverse /rest/ http://localhost:8080/Hornet/rest/
# Send to Node
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
</VirtualHost>