重写一个php文件以生成robots.txt


Rewrite one php file to generate robots.txt

我有一个非常简单的问题。

我有一个非常简单的php问题,名称为:robots.php

现在,我想将此文件更改为robots.txt

如何更改此文件url?

在Web空间的根目录中创建一个htaccess文件,其中包含以下内容:

RewriteEngine on
RewriteRule ^robots'.txt$ /robots.php [L]

对于robots.txt 的每个请求,服务器都会使用robots.php进行响应