2014-02-28 45 views
1

我不明白任何.htaccess,我需要重定向缓存。如果文件存在(缓存),在.htaccess中重定向

目前使用以下规则: RewriteRule ^movie/(.*)/(.*)/(.*)$ app.php?view=movie&theatre=$1&ordem=$2&movie=$3 [L,QSA]

也就是说,请求的URL movie/jardins/0/robocop

重定向到

app.php?view=movie&theatre={jardins}&ordem={0}&movie={robocop}

但我想,如果文件存在重定向api/cache/html/{jardins}/{0}/{robocop}.html

回顾{jardins}和{0}是目录。

如何做到这一点? :(

+0

您可以使用['RewriteCond'(http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond)指令。 – hjpotter92

+0

@ hjpotter92就像我知道的:( – Theus

+0

你能澄清一下这个文件会是什么以及你想要重定向这个文件吗? –

回答

0

您可以:

RewriteEngine On 
RewriteBase/

RewriteCond %{DOCUMENT_ROOT}/app/cache/html/$1/$2/$3\.html -f [NC] 
RewriteRule ^movie/(.*)/(.*)/(.*)$ app/cache/html/$1/$2/$3.html [L,NC] 

RewriteRule ^movie/(.*)/(.*)/(.*)$ app.php?view=movie&theatre=$1&ordem=$2&movie=$3 [L,QSA] 
+0

太棒了!它完美的工作。谢谢:) – Theus

+0

不客气,很高兴它解决了。 – anubhava

相关问题