.htaccess重写除robots.txt和sitemap.xml以外的所有文件


.htaccess rewrite for all but robots.txt and sitemap.xml

我有一个简单的PHP MVC架构,可以通过public/index.PHP路由所有请求。我使用.htaccess来路由所有请求,还可以强制执行"wwww"answers"https",但我不知道如何排除robots.txt和sitemap.xml。以下是我目前拥有的:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example'.com$ [OR]
    RewriteCond %{HTTPS} !on
    RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
    RewriteRule    ^$    public/    [L]
    RewriteRule    (.*) public/$1    [L]
</IfModule>

如有任何意见,我将不胜感激。

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example'.com$ [OR]
    RewriteCond %{HTTPS} !on
    RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
    RewriteRule    ^$    public/    [L]
    RewriteRule ^((?!robots'.txt|sitemap'.xml).*) public/$1    [L]
</IfModule>

上面的模式((?!robots.txt|sitemap.xml).*)匹配除/arobots.txt/sitemap.xml.

之外的任何请求