使用PHP动态地添加到.htaccess文件?

编程入门 行业动态 更新时间:2024-10-24 04:48:40
本文介绍了使用PHP动态地添加到.htaccess文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我所要做的是自动化与网站上线的过程。这些网站正在使用htaccess的所有动态创建的,所以这里是一个例子:

What I am trying to do is automate the process of going live with websites. These websites are all dynamically created using htaccess, so here is an example:

RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteCond %{HTTP_HOST} ^(www\.)?domain\$ [NC] RewriteRule ^(.*)$ /folder%{REQUEST_URI}?%{QUERY_STRING} [QSA,L]

我要做的就是添加域别名的 domain 的,然后将其指向我的服务器IP和htaccess文件使得查看什么是在/文件夹。

What I do is add a domain alias for domain, and then point it to my server IP and the htaccess file makes it view what is in the /folder.

它工作正常,但我们计划有数百个网站,并加入code的片段来htaccess的手动可以获得$ ​​P $ ptty的讨厌。由于所有我改变是的 domain 的和的 /文件夹的,有没有办法用PHP动态添加到.htaccess文件的底部,如果我创建了一个形成并告诉它的域和文件夹,将其添加到htaccess文件的底部?

It works fine but we are planning to have hundreds of websites and adding that snippet of code to the htaccess manually can get pretty annoying. Since all I am changing is domain and the /folder, is there a way to use PHP to dynamically add to the bottom of the .htaccess file if I create a form and tell it the domain and the folder, it will add it to the bottom of the htaccess file?

这将节省很多时间。

太感谢了。

推荐答案

我真的不建议让PHP来增加任何事情成的.htaccess,这是一个很大的安全隐患。

I really do not recommend to allow php to add ANYTHING into .htaccess, it's a big security risk.

//but here is your code $f = fopen(".htaccess", "a+"); fwrite($f, "your content"); fclose($f);

更多推荐

使用PHP动态地添加到.htaccess文件?

本文发布于:2023-10-31 16:32:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546644.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   动态   PHP   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!