首页 > 解决方案 > 结合两个 RewriteRules 覆盖第一个

问题描述

我正在尝试同时应用两个 RewriteRules。它们都完全按照预期独立工作(当另一个被注释掉时),但是当.htaccess一起放在文件中时,只有第一条规则有效。

我怎样才能一起使用这些?

RewriteEngine On

# Redirect everything to this file
RewriteRule ^ public/index.php [QSA,L]

# Rewrite location of the storage files making them public
RewriteRule ^storage/(.*)$ app/files/public/$1 [QSA]

标签: htmlapache.htaccessmod-rewrite

解决方案


感谢@CBroe的帮助,这是解决方案:

RewriteEngine On

# Rewrite location of the storage files making them public
RewriteRule ^storage/(.*)$ app/files/public/$1 [QSA,L]

# Redirect everything to this file
RewriteRule ^ public/index.php [QSA]

推荐阅读