Forum Moderators: coopster
The homepage is the only page that exists in the domain root folder. All the others are in the "cms" subfolder, which is given chmod 777 permissions so that they can be created. I am using .htaccess to rewrite URLs such as /mypage into /cms/mypage.php - so that all the pages appear to be in the root folder.
Is there an alternative way to do this without .htaccess? The root folder has chmod 750 permissions and I am looking for a way to achieve all URLs as /mypage and not /cms/mypage or /cms/mypage.php etc.
The path prefix "/cms/" could be in a global variable somewhere in which case it could just be redefined. Otherwise just locate where the code assigns the file and adapt as necessary.
You may need to maintain your existing re-writes for historical content which you're unable to move, in which case, it might be an idea to take it out of .htaccess and put it in httpd.conf in order to save parsing .htaccess with every connection.
TJ
I would have thought you could simply amend the php script to place the newly created pages in the correct directory.The path prefix "/cms/" could be in a global variable somewhere in which case it could just be redefined. Otherwise just locate where the code assigns the file and adapt as necessary.
Thanks for the reply. If I want to place the newly created pages in the root folder, then wouldn't I need to set the chmod to 777? A security issue?
I'm not sure what you mean by "Otherwise just locate where the code assigns the file and adapt as necessary."
I'm not sure what you mean by "Otherwise just locate where the code assigns the file and adapt as necessary."
I assumed that your CMS is based on some form of script that creates the files required, the text file and the .php file that includes the text. You need to locate that script and edit it so that the php files are written out to / rather than to /cms/. The path to the text files may need to also be changed to reflect the new location if the php file does not use absolute paths. Trial and error on a local PC running Apache with a complete copy of the site is the most useful tool for this kind of work.
The underlying "user", as far as the OS is concerned, is whichever user you are running Apache under. That user needs to have write access to the "/" folder to be able to save the files there.
TJ
touch(): open_basedir restriction in effect.
I'm assuming my host doesn't allow the root folder to be fully writable, or something. The security issue I am concerned about is making the root folder into chmod 777, even if I was allowed to. I have written this simple CMS myself but am at the limits of my expertise, especially with server configuration, and also with global variables.
If you wrote the CMS, I'm not entirely sure why you cannot output the files to wherever within the site structure you want them to be?
There is no difference, in terms of permissions, between "/index.html" and "/cms/index.html". Both are readable from the web, and both should be writable by you.
TJ
Thanks for the replies. I'll see how it goes. Ideally, I was hoping to have found a way to place the files in a subfolder and still have them appear as if in public_html, as does for example WordPress, but without the need for .htaccess... as a learning thing, really, and for the sake of elegance.
Another reason is that someone else using this CMS might not be able to chmod public_html to 777.
Sorry if this seems garbled. Perhaps this can't be done.
I can't say I really understand the security risk associated with making folders writable - maybe it's very low, especially as there are no publicly accessible input forms - but the real issue is to make the pages appear and behave as if they are in public_html for the reasons above, even on a Windows server if needs be.
If the pages were dynamic (from a database) then there wouldn't be an issue because there would be no need for the (writeable) /cms/ subfolder. But my system creates actual files for the pages.
normally an attacker tries to gain root access on the machine so she/he has got all rights needed to own the box. within in this process (which is mainly based on "not intended" functions, so called exploits), it can help an attacker to have the possibility to create files. i think basically that's all about the writing permissions.
generally spoken, i do not think that it is definitely a must to have write permissions disabled to harden a shared host.
lets say the file is called test.php located in /, the according url is:
www.sample.dom/test or www.sample.dom/test/some/more/stuff
so i thought with a index.php this would be the key, but that did not work out with that specific setup but indexes are quite irregular on that hoster. i knew it worked with www.sample.dom/test.php/some/more/stuff as for se-friendly links, but not without the .php extension.