为什么这在 WordPress function.php 中不起作用?

发布于 2024-12-05 00:21:46 字数 1264 浏览 1 评论 0原文

$file = 'my/path/to/htaccess/location/.htaccess';

$htaccess = file($file);

$ht = fopen($htaccess,'a');

fwrite($ht,"deny");

fclose($ht);

我正在尝试通过functions.php修改.htaccess文件,CHMOD设置为777,有什么想法吗?

编辑:

刚刚启用的错误:

Warning: file() [function.file]: URL file-access is disabled in the server configuration in /home/tfbox/domains/ibrogram.com/public_html/themes/beta/wp-content/themes/beta/functions.php on line 133

Warning: file(http://themes.ibrogra.com/beta/.htaccess) [function.file]: failed to open stream: no suitable wrapper could be found in /home/tfbox/domains/ibrogram.com/public_html/themes/beta/wp-content/themes/beta/functions.php on line 133

Warning: fopen() [function.fopen]: Filename cannot be empty in /home/tfbox/domains/ibrogram.com/public_html/themes/beta/wp-content/themes/beta/functions.php on line 135

Warning: fwrite(): supplied argument is not a valid stream resource in /home/tfbox/domains/ibrogram.com/public_html/themes/beta/wp-content/themes/beta/functions.php on line 137

Warning: fclose(): supplied argument is not a valid stream resource in /home/tfbox/domains/ibrogram.com/public_html/themes/beta/wp-content/themes/beta/functions.php on line 139
$file = 'my/path/to/htaccess/location/.htaccess';

$htaccess = file($file);

$ht = fopen($htaccess,'a');

fwrite($ht,"deny");

fclose($ht);

I'm trying to modify the .htaccess file via functions.php, the CHMOD is set to 777, any ideas?

Edit:

Just enabled errors:

Warning: file() [function.file]: URL file-access is disabled in the server configuration in /home/tfbox/domains/ibrogram.com/public_html/themes/beta/wp-content/themes/beta/functions.php on line 133

Warning: file(http://themes.ibrogra.com/beta/.htaccess) [function.file]: failed to open stream: no suitable wrapper could be found in /home/tfbox/domains/ibrogram.com/public_html/themes/beta/wp-content/themes/beta/functions.php on line 133

Warning: fopen() [function.fopen]: Filename cannot be empty in /home/tfbox/domains/ibrogram.com/public_html/themes/beta/wp-content/themes/beta/functions.php on line 135

Warning: fwrite(): supplied argument is not a valid stream resource in /home/tfbox/domains/ibrogram.com/public_html/themes/beta/wp-content/themes/beta/functions.php on line 137

Warning: fclose(): supplied argument is not a valid stream resource in /home/tfbox/domains/ibrogram.com/public_html/themes/beta/wp-content/themes/beta/functions.php on line 139

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

隐诗 2024-12-12 00:21:46

$file = 'http://'.$_SERVER['SERVER_NAME'].'/beta/.htaccess';

使得请求的路径成为 http 路径。

这没有意义 - 你想使用文件路径。

你可以用它

$file = $_SERVER['DOCUMENT_ROOT'].'/beta/.htaccess';

来代替。

This

$file = 'http://'.$_SERVER['SERVER_NAME'].'/beta/.htaccess';

makes the requested path a http path.

That doesn't make sense - you want to use a file path.

You could use

$file = $_SERVER['DOCUMENT_ROOT'].'/beta/.htaccess';

instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文