2013-02-28 105 views
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] 

感謝您的幫助!

回答

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]