1

好的,所以我的 httpd.conf 上有这个重写规则

<Directory /var/www/html/dev/html5>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/?(.*)/(.*)$
RewriteRule ^.*$ snapshots/playlist-%2\.html [NC,L,PT]

RewriteCond %{HTTP_USER_AGENT} ^Mozilla(.*)MSIE\ 9.0(.*)$ [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}/dev/html5/#!/$1 [R,NC,NE,L]

RewriteRule ^.*$ index.html [NC,L,PT]

我感兴趣的是,当我在查询字符串中有 _escaped_fragment

RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/?(.*)/(.*)$

我想查找文件夹快照,但该文件夹不在 html5 文件夹内,是上一级的,那么我该如何查找该文件夹?像这样

RewriteRule ^.*$ ../snapshots/playlist-%2\.html [NC,L,PT]

谢谢你的帮助!

4

1 回答 1

1

首先,您需要通过将其添加到您的虚拟主机配置中来允许该文件夹权限

换句话说,您需要配置 apache 以允许该文件夹,因此就像<directory icons>默认<directory error docs>设置一样。也许将其设为别名:

Alias /snapshots/ "/var/www/html/dev/snapshots/"
<Directory "/var/www/html/dev/snapshots/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

然后,一旦它被别名,它将在 example.com/snapshots/ 上可用,所以

RewriteRule ^.*$ /snapshots/playlist-%2\.html [NC,L,PT]
于 2013-02-28T22:05:22.240 回答