For my app I decided to change the directory of static and public content to another domain.
However, I had troubles about the copy of files into folders.
I decided to restrict the access of subdomain to a specific path. Indeed, when you log in to the ftp, you can't show the subfolders
So atm, this is what I have :
A domain www.domain.com
A subdomain www.static.domain.com
Ftp logs which only allow me to show the content of www.static.domain.com
Then, I wish to copy files and directories after user's register. I can create folders, but I can't copy files...
The getcwd() function returns me this :
/datas/vol2/xxxx/var/www/domain.com/htdocs
instead of
/datas/vol2/xxxx/var/www/static.domain.com/htdocs
That's why I can't copy the index.html file at the root of the subdomain to each folders i'm going to create.
Do you have any ideas about that ?
Thanks for answers
T
What about the "copy" or "move" Command?
Related
I am taking over a website from a sister company and their site has several places where a folder will have a sub folder and a .php file with the same name. For example, the parts folder will have a store folder that contains several more files and folders but it contains a store.php file as well. nginx is throwing a forbidden error because it thinks the user is trying to list the folder directory but the url /parts/store/ should show the store.php file and still allow the user to go to /parts/store/category/product and should show a product file nested in the parts/store/ sub folders.
One option would be to rename the files you want to be directory index as indes.php if your Nginx configuration allows for that. That in my mind is the simplest solution and is most inline with web standards.
I installed two codeigniter for desktop and mobile version. My directory structure is as follows:
www/projectfordesktop/application
www/projectfordesktop/uploads
www/projectfordesktop/projectformobile/application
My problem is that when I upload files from mobile site I want my file to be uploaded in main codeigniter application www/projectfordesktop/uploads. So, I want to access main codeigniter application base_url to www/projectfordesktop/projectformobile/. How is it possible.
I made two project because it redirect to m.project.com when accessed from mobile. And when access from desktop project.com. Is it good idea. If not, then is there any way I can use seperate view for mobile and desktop. Please help.
Thank you.
For security and a bunch of other reasons you absolutely do not want the upload folder in your application folder. And if at all possible you want your application folder and system folder above the public root. The other consideration - its possible and in some ways desirable to rename your application and system folder. So if your public folder is www
desktopapplication/www/
mobileappliction/www/
system306/www/
Now they are all safely above the public www, and they are labeled for what they are. Next you can have folders in the public folder, that contain the main index.php file for the specific application.
www/projectfordesktop/index.php
www/projectformobile/index.php
Open up the index.php file and redo the file paths to the application and system folder. Like
$system_path = '../../system306';
$application_folder = '../../desktopapplication';
The upload folder will now be either in www or one of the folders like projectfordesktop. Typically you would also put your css, js, etc files in there as well.
www/projectfordesktop/upload/
www/projectfordesktop/css/
www/projectfordesktop/js/
www/projectfordesktop/img/
Now - all the files which are public - are in a public folder. All the files which should be kept private - your application and system folder - are not public. And because you have labeled your application and system folder it makes it much easier to switch to different versions or revert back if needed.
Is it possible to include file from the ftp's root in a script in a subdomain ?
This doesn't work for me:
include($_SERVER['DOCUMENT_ROOT'].'/joomla.php');
Can someone help me ?
I think first you need to determine where is your subdomain files are placed and echo the $_SERVER['DOCUMENT_ROOT'] command to see the full path then you can combine two paths and make necessary adjustments.
Usually but not always, subdomain files are placed in a folder one level up then the main site's root folder so you may need to replace the folder name according to your needs in the output of server document folder function.
To give an example if your domain files are in a path like
/var/www/vhosts/example.com/httpdocs/
and if your subdomain path is like
/var/www/vhosts/example.com/subdomain/
then you will need to replace httpdocs with subdomain (or the other way around) in the output where you call $_SERVER['DOCUMENT_ROOT']
how can i know where is my web root folder ?
and how to put folders out of web root folder?
and how to test that they are not accessible from outside ?
the structure of my hosting is like this:
www.website.com :
public_html/
includes /
logs/
...
is it enough to protect includes folder and logs folder with htaccess? and are they out of web root in this case?
i know that $server[document root] provide the root of my website , but i am confused about how to put files out of it , any help would be welcome , thanks for all
All your files are currently in the public web root folder.
The 'inside' of your root is your publichtml/. Everything you place in there will be publicly accessible.
The name of your root can vary from host to host, often public_html or httpdocs.
The 'outside' is one directory up. But remember some hosts do not give enough permissions.
You cannot test documents outside your root, because they are not accessible. Only something like PHP can access those files. That's why you do not place your img/JS/CSS files outside the root cause they need direct access.
You can however serve them through your PHP.
I have a CakePHP project uploaded to the server:
httpdocs/cakephp/app/...
My domain name, for example www.mydomain.com is directed to httpdocs/cakephp
Now.. I need to access an image folder that it's otside the webroot of CakePhp:
httpdocs/resources/images/...
The problem is that I can't see files outside the cakephp folder when I go to www.mydomain.com, If I try with ../../resources/images.... I just get www.mydomain.com/resoures/images with an error.
How can I solve this?
Thank you!
Just symlink the resouces folder in your webroot folder.
Alternatively you can send the files through php. The CakePHP book describes this here for >2.3 and here.
Also it is not a good idea to put the whole cake folder in the root of your domain, you should set your app/webroot has the root of your host.