Nginx Directory Permission Control

Source: Internet
Author: User
Nginx Directory permission Control Help

server {
Listen 80;
server_name admin.my.com;

Location/{
Root d:/www/webroot;
Index index.php;
}

error_page404 = http://admin.my.com/error.html;

Location ~ \.php$ {
Rootd:/www/webroot;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
Fastcgi_paramscript_filename D:/www/webroot$fastcgi_script_name;
Includefastcgi_params;
}
}


fastcgi.conf Configuration

The URL structure of my system (non-pseudo-static, just converted in the portal file): for example:
Http://admin.my.com/index.php/Index/image
_code
Http://admin.my.com/index.php/Admin/edit_config
Http://admin.my.com/index.php/News/add
......
index.php is a portal file, single entry

But the problem came when I visited Http://admin.my.com/index.php/Index/image_code.
In fact, the file path points to: d:/www/webroot/index.php/index/image_code/index.php
Because the location above is configured: Index index.php; Probably the suffix name in the URL is not PHP or HTML or other "physical existence" of the file, will automatically add index.php it, right??????????????????

My goal is: No matter how many slash-index.php behind the URL, the entry file can only be the front index.php, instead of the following parameters into the directory and automatically add index.php.

I know this URL structure is very irregular, but the current change to more trouble, time relationship, so in the thought there is no way to solve through nginx configuration. Seek the Great God, and beg the great fairy, thank you.

The feeling is still Apache good, all of a sudden took care of:


Serveradmin[email protected]
DocumentRoot/
ServerName admin.my.com
Alias/ "d:/www/webroot/"

Options followsymlinksmultiviews execcgi

Order Allow,deny
Allow from all

Errorlog Logs/admin-error.log
#CustomLog Logs/admin-access.log Common

Nginx Apache Server


------Solution--------------------
Location ~ \.php$
Removing PHP after the $ regular in $ means the end. The removal also tells Nginx to give all. php* files to FPM processing, not just. php.
Then change the execution file name to index.php
Fastcgi_param Script_filename d:/www/webroot/index.php;
The rest depends on your application.

This is a relatively simple configuration, want to know more perfect method, to search it yourself, this is really too much explanation
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.