Configure nginx to use files and folders with the same name - php

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.

Related

PHP - How to use the same set of files in each subdirectory?

You see how facebook works, like if my profile is
www.facebook.com/myusername
then there is a specific index.php file and other lots of files that open when I open facebook.com/myusername.
Now I believe it is highly unlikely that Facebook copied the same files into each and every user's username directory.
How else would it work?
I'll be having many different users using the same application, i.e. the same set of files with minor changes in one or two files. Do I necessarily have to copy all the files into all the user directories each time?
I tried putting an index.php file in the subdirectory that contains this code:
<?php
require '../index.php';
?>
Now even though that runs the ../index.php file inside the subdirectory, but when the ../index.php file redirects to say another file named 'otherfile.php', then it gives a 404 not found error, because 'otherfile.php' is not present in the subdirectory, it is present in the parent directory.
How do I solve this problem?

Nested codeigniter and how to get relative path of main codeigniter folder

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.

mkdir() or chmod() set directories contents to hidden, but subdirectories contents to viewable

I'm creating a file-based storage system for small indie game developers to use with their games. It's all controlled by a single PHP file, that handles 'queries' via POST / GET variables. I want the PHP file to create a directory that holds sub-directories (one for each game). I dont want anyone to view the games within this main directory, so they cant view other games IDs, but if they have their games ID, they can view the contents of their games folder.
Here's the main directory that holds the game directories:
http://shadespeed.com/shadetech_storage/
I want to hide all of the contents within that folder, but show contents within the sub-directories, such as this:
http://shadespeed.com/shadetech_storage/12345678/
Is this possible?
Looking at chmod(), I can't find any modes that do what I want: http://www.php.net/manual/en/function.chmod.php
Many thanks,
Dan.
I've used workaround. I simply created an HTML file (index.html) in the main directory. It works for now, but I'm not sure if it will stop people who know what they're doing.
Probably you should simple create .htaccess file with content:
Options -Indexes
You can simple put it in main folder when you don't want users to display files in this directory so in your case probably in directory http://shadespeed.com/shadetech_storage/
If your server is Apache based, simply use an .htaccess file in the main directory that forbids access to that directory content (as in Code 1), and .htaccess files in each subdirectory in order to allow access to them (as in Code 2)
Code 1:
Order deny,allow
Deny from all
Code 2:
Order allow,deny
Allow from all

Upload file on a subdomain

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?

How do I get symlinked files to see non-symlinked directories

I have a batch of files in
/home/***/construct/
which I have symlinked to the subdomain 'http://sampleaccount.mywebsite.com' so that the '/constuct/' directory appears in that subdomain's specific directory tree.
The files within '/construct/' are master page-layout files that include PHP includes to a '/bodyCopy/' directory within the 'sampleaccount' subdomain. For example:
<?php include("bodyCopy/copy-content.php"); ?>
BUT...
I keep getting an error on my Web page that indicates PHP is searching for the 'copy-content.php' file in the '/bodyCopy/' directory in /home/*/construct/ (which does not exist) instead of in the '/bodyCopy/' directory located within 'http://sampleaccount.mywebsite.com', as in...
http://sampleaccount.mywebsite.com/bodyCopy/copy-content.php
Therefore, how do I make the symlinked master page-layout files search the current directory TO WHICH THEY ARE LINKED search for the '/bodyCopy/' directory in the 'sampleaccount' subdomain instead of it searching the root?
The caveat is that the '/construct/' directory in root will be symlinked to multiple subdomain accounts, each with their own '/bodyCopy/' directories, so I cannot use a hard link in the master page-layout files.
Thanks in advance for any solutions provided. -- Jet
<?php include("/rootfoldername/bodyCopy/copy-content.php"); ?>
or
<?php include("../bodyCopy/copy-content.php"); ?>

Categories