【发布时间】:2012-10-05 14:53:30
【问题描述】:
我想要做什么:
如果文件不存在,我需要将对文件的请求重定向到另一个域。例如:
http://www.mydomain.com/js/foo.js
重定向到(如果不存在)
http://www.myanotherdomain.com/js/foo.js
我做什么:
我在 htaccess 的末尾写了下一行,但它们重定向了所有!
RewriteCond %{REQUEST_URI} !-f
RewriteRule ^(.*)$ http://www.myanotherdomain.com/$1 [L,NC]
在这些行之前,我有很多这样的行(我正在使用 MVC (Model, View,Controller)):
RewriteRule ^car/brand/?$ ?controller=Car&action=viewBrand [L,NC]
会发生什么:
它适用于不存在的文件,但似乎与 MVC 规则不兼容。这些规则必须匹配然后停止评估规则,因为 de "L" 标志。但它似乎继续评估规则并最终评估重定向规则。结果是这样的:
http://www.mydomain.com/car/brand/
去
http://www.myanotherdomain.com/?controller=Car&action=viewBrand
谁能帮帮我?
非常感谢,
乔纳森
【问题讨论】:
标签: mod-rewrite redirect