如何在我的 .htaccess 文件中允许 robot.txt

how can I allow robot.txt in my .htaccess file

我正在尝试使 robots.txt 和 favicon.ico 可通过 http 访问。它们都在我的应用程序的根目录中。我希望他们能够访问 mydomain.com/robots.txt 和我的 robots.txt 文件,与 favicon.ico 相同。我查看了互联网上的其他示例和堆栈溢出,但我似乎无法使其适用于我的特定 .htaccess 文件。

RewriteEngine on
RewriteCond %{REQUEST_URI} !=/server-status
RewriteRule ^folder1/(.+)?$ folder1/ [L]
RewriteRule ^folder2/(.+)?$ folder2/ [L]
RewriteRule ^folder3/(.+)?$ folder3/ [L]
RewriteRule ^folder4/(.+)?$ folder4/ [L]
RewriteRule ^robots.txt [L]
RewriteRule ^favicon.ico [L]
RewriteBase /
RewriteRule !\.(gif|jpg|jpeg|png|css|js|php|htaccess|xml|htm|html|swf|pdf)$ index.php

<ifModule mod_headers.c>

# Expires after 1 month
<filesMatch ".(css|js)$">
Header set Cache-Control "max-age=2592000"
</filesMatch>

# Expires after 1 day
<filesMatch ".(jpg|jpeg|gif|png|x-icon)$">
Header set Cache-Control "max-age=31536000"
</filesMatch>
</ifModule>

这有效:

RewriteEngine on
RewriteCond %{REQUEST_URI} !=/server-status
RewriteRule ^folder1/(.+)?$ folder1/ [L]
RewriteRule ^folder2/(.+)?$ folder2/ [L]
RewriteRule ^folder3/(.+)?$ folder3/ [L]
RewriteRule ^folder4/(.+)?$ folder4/ [L]
RewriteRule "^robots.txt$" "robots.txt" [L]
RewriteRule "^favicon.ico$" "favicon.ico" [L]
RewriteBase /
RewriteRule !\.(gif|jpg|jpeg|png|css|js|php|htaccess|xml|htm|html|swf|pdf)$ index.php

<ifModule mod_headers.c>

# Expires after 1 month
<filesMatch ".(css|js)$">
Header set Cache-Control "max-age=2592000"
</filesMatch>

# Expires after 1 day
<filesMatch ".(jpg|jpeg|gif|png|x-icon)$">
Header set Cache-Control "max-age=31536000"
</filesMatch>
</ifModule>