如何在.htaccess重写中排除robots.txt

问题描述 投票:0回答:1

我希望我的robots.txt可以访问,但我无法做到这一点。我在这里运行有角度的应用程序,这就是为什么我需要这些重写。

这是我目前在.htaccess中拥有的内容:

RewriteEngine on

RewriteRule ^robots.txt - [L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L]

RewriteRule ^(.*) /index.html [NC,L]

显然不起作用:

apache2-log:[perdir /var/www/app/] applying pattern '^robots.txt' to uri 'index.html'

我在做什么错?

.htaccess mod-rewrite apache2
1个回答
0
投票

要排除文件,请尝试如下操作:

RewriteCond%{REQUEST_URI}!^ /您的文件名。文件扩展名$

© www.soinside.com 2019 - 2024. All rights reserved.