我所要做的是自动化与网站上线的过程。这些网站正在使用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文件?
发布评论