htaccess重写多个条件

时间:2017-07-17 12:20:15

标签: apache .htaccess mod-rewrite url-rewriting

我有以下.htaccessindex.php提供服务,并阻止显示.txt个静态文件。

我想添加一个附加规则:将example.com/re重定向到example.com/re.php。怎么做?

这失败了,我不知道为什么:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^re$ re.php       //fail: style.css won't be accessible anymore, leading to broken website
RewriteRule ^(.*)$ index.php [QSA,L]
RewriteRule \.txt$ index.php [L]

1 个答案:

答案 0 :(得分:1)

正如@CBroe在评论中所指出的, RewriteCond仅影响直接跟随RewriteRule ,因此这是解决方案:

SELECT UPPER(company_name), vat, company_owner_email FROM (
    (SELECT company_name, vat, admin.email as company_owner_email FROM pub
        LEFT JOIN admin ON pub.manager = admin.id
        WHERE company_name > '')
        UNION
    (SELECT company_name, vat, admin.email as company_owner_email FROM adv
        LEFT JOIN admin ON adv.manager = admin.id
        WHERE company_name > '')
    ) company
GROUP BY replace(replace(replace(replace(company_name,'\t',''), ' ', ''), '.', ''), ',','')
ORDER BY company_name;