首页 > 解决方案 > Mod_rewrite 忽略条件

问题描述

Apache 似乎忽略了以下条件。我试图确保如果请求 URI 中包含站点地图一词,则不执行重写规则。例子:

http://www.mysites.com/sitemaphttp://www.mysites.com/sitemap/users/sitemap1.gz

<IfModule mod_proxy_http.c>
    RewriteCond %{HTTP_USER_AGENT} googlebot|google-structured-data-testing-tool|semrushbot|applebot|bingbot|yandex|baiduspider|ahrefsbot|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest\/0\.|pinterestbot|slackbot|vkShare|W3C_Validator|whatsapp [NC,OR]
    RewriteCond %{QUERY_STRING} _escaped_fragment_
    RewriteCond %{REQUEST_URI} ^(?!.*?(\.js|\.css|\.xml|\.less|\.png|\.jpg|\.jpeg|\.gif|\.pdf|\.doc|\.txt|\.ico|\.rss|\.zip|\.mp3|\.rar|\.exe|\.wmv|\.doc|\.avi|\.ppt|\.mpg|\.mpeg|\.tif|\.wav|\.mov|\.psd|\.ai|\.xls|\.mp4|\.m4a|\.swf|\.dat|\.dmg|\.iso|\.flv|\.m4v|\.torrent|\.ttf|\.woff|\.svg))
    RewriteCond %{REQUEST_URI} !^/sitemap(/|$)

    RewriteRule ^(index\.html|index\.php)?(.*) https://service.prerender.io/%{REQUEST_SCHEME}://%{HTTP_HOST}/$2 [P,L]
</IfModule>

Apache 似乎只是忽略了这一点并执行代理请求。有任何想法吗?

标签: apache.htaccessmod-rewrite

解决方案


好吧,我的坏:

RewriteCond %{REQUEST_URI} !^/sitemap(/|$)

本来应该:

RewriteCond %{REQUEST_URI} !^sitemap

推荐阅读