且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用PHP编写.htaccess文件?

更新时间:2023-12-04 13:44:22

您可以使用的fopen 开和的 FWRITE 以写入文件。你会想打开它附加模式,阅读手册,看​​看哪些应用。

You can use fopen to open and fwrite to write to a file. You'll want to open it in append mode, read the manual to see which applies.

不过,这听起来像一个奇怪的方式去做事。

That said, this sounds like a strange way to go about doing things.

我完成你想只使用重写检查文件$ ​​P $ psence规则做:

I accomplish what you're trying to do using just rewrite rules that check for file presence:

RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /maintenance.html [L]

如果该maintenance.html文件是present,那么我的网站正在维护中。

If the maintenance.html file is present, then my site is under maintenance.