如何从以下.htaccess重写规则中排除特定文件类型

时间:2016-08-07 18:14:32

标签: apache .htaccess mod-rewrite

我需要帮助排除.xml站点地图以添加尾部斜杠规则。

这是htaccess代码

<IfModule mod_rewrite.c> 
Options +FollowSymLinks -MultiViews

RewriteEngine On 
RewriteBase /

#www to non
RewriteCond %{HTTP_HOST} ^www\.(([a-z0-9_]+\.)?ghadaalsaman\.com)$ [NC]
RewriteRule ^(.+?)/?$ http://%1/$1/ [R=301,L]

RewriteCond %{THE_REQUEST} \s/+(.+?)\.html/?[\s?] [NC]
RewriteRule ^ /%1/ [R=301,NE,L]

#index redirect 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/ 
RewriteRule ^index\.html$ http://%{HTTP_HOST}/ [R=301,L]

# add a trailing slash to non files
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*?[^/])$ %{REQUEST_URI}/ [L,R=301]

# add html internally
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^.]+)/$ $1.html [L]

</IfModule>

感谢@anubhava的帮助

1 个答案:

答案 0 :(得分:2)

我已经通过添加

解决了这个问题
RewriteCond %{REQUEST_URI} !sitemap [NC]