How to create or edit the contents of a file in the root directory

I have one website, but I don’t want it, when I upload this website to a live server, it should request a username, password, website URL..etc. Something like a website installer. It works fine on the local system.

Now my problem is: I need to change the RewriteBase in the .htaccess file. But this file is at the root of the site. Therefore, I get permission to create a new file or edit / copy a file that is in the root.

Warning: rename (generate.htaccess, .htaccess): Permission denied

Warning: copy (.htaccess): could not open stream: Permission denied

What should I do. Please, help.

Thanks.

+6
source share
1 answer

To create / modify a file in the root directory, you need to grant permission 0777 to your root directory. This is not a good practice.

I suggest that you first create an empty .htaccess or other required file with a resolution of 777. Before writing content in this file, first check the write permission after that contents of the copy from the source file (in your case, from where you are trying to copy).

Hope this helps.

+7
source

Source: https://habr.com/ru/post/916525/


All Articles