search
HomeBackend DevelopmentPHP Tutorial Nginx Alias 无法解析PHP的解决方法

Nginx Alias 无法解析PHP的解决办法

Nginx Alias 无法解析PHP的解决办法:

server {
??????? listen?????? 80;
??????? server_name? xxxx.com.cn;


??????? error_log? /tmp/eror.log;
??????? set $www_root /home/web/yqbb/bgskk;


??????? location / {
??????????? root?? $www_root;
??????????? index? index.html index.php;
??????? }


??????? location /feedback {
??????????? index? index.php;
??????????? alias /home/web/yqbb/bgskk/app/htdocs;
??????? }


??????? error_page?? 500 502 503 504? /50x.html;
??????? location = /50x.html {
??????????? root?? html;
??????? }


??????? location ~ ^/feedback/.+\.php$ {
??????????????? root /home/web/yqbb/bgskk/app/htdocs;
??????????????? rewrite /feedback/(.*\.php?) /$1 break;
??????????????? include fastcgi.conf;
??????????????? fastcgi_pass?? 127.0.0.1:9000;
??????????????? fastcgi_index? index.php;
??????????????? fastcgi_param SCRIPT_FILENAME /home/web/yqbb/bgskk/app/htdocs/$fastcgi_script_name;
??????? }


??????? location ~ .*\.(php|php5)?$ {
??????????????? fastcgi_pass? 127.0.0.1:9000;
??????????????? fastcgi_index index.php;
??????????????? include fastcgi.conf;
??????? }


??? }


?

?

server
??? {
??????? listen 80;? #端口号
??????? server_name www.linuxidc.com;?? #域名
??????? index index.html index.htm index.php index.shtml;? #默认首页
??????? root? /var/www/html;? #网站根目录
??????? charset gbk;??? #默认编码

??????? location /public/? #设定要重写的目录名
??????? {
??????????????? alias /var/www/public/; #重定向目的目录。

??????????????? #例:如果用户访问http://www.linuxidc.com/public/test.html 不会访问/var/www/html/public/test.html,而访问的是/var/www/public/test.html,虽然这个文件并没有在域名目录下
??????? }

#做完上面的设置后,我们发现访问PHP文件http://www.linuxidc.com/public/test.php时,还是去访问了/var/www/html/public/test.php,也就是说访问php文件没有起到重定向的作用,所以我们还要配置如下这段

#start


??????? location ~ ^/public/.+\.php$
??????? {
??????????????? root /var/www/html/web/news/public;
??????????????? rewrite /public/(.*\.php?) /$1 break;
??????????????? include fastcgi.conf;
??????????????? fastcgi_pass?? 127.0.0.1:9000;
??????????????? fastcgi_index? index.php;
??????? }

#end


??????? location ~ .*\.(php|php5)?$
??????? {
??????????? #fastcgi_pass? unix:/tmp/php-cgi.sock;
??????????? fastcgi_pass? 127.0.0.1:9000;
??????????? fastcgi_index index.php;
??????????? #include fcgi.conf;
??????????? include fastcgi.conf;
??????????? rewrite? ^/([a-zA-Z]+)\/([a-zA-Z]+)$ /$2.shtml last;
??????? }

??????? location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
??????? {
??????????? expires????? 30d;? #缓存30天
??????? }

??????? location ~ .*\.(js|css)?$
??????? {
??????????? expires????? 1h; #缓存1个小时
??????? }

??????? access_log? /var/log/linuxidc.log? access;? #定义日志文件
??????? ssi on;
??????? ssi_silent_errors on;
??????? ssi_types text/shtml;
??? }

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What is PDO in PHP?What is PDO in PHP?Apr 28, 2025 pm 04:51 PM

The article discusses PHP Data Objects (PDO), an extension for database access in PHP. It highlights PDO's role in enhancing security through prepared statements and its benefits over MySQLi, including database abstraction and better error handling.

What is Memcache and Memcached in PHP? Is it possible to share a single instance of a Memcache between several projects of PHP?What is Memcache and Memcached in PHP? Is it possible to share a single instance of a Memcache between several projects of PHP?Apr 28, 2025 pm 04:47 PM

Memcache and Memcached are PHP caching systems that speed up web apps by reducing database load. A single instance can be shared among projects with careful key management.

What is PEAR in PHP?What is PEAR in PHP?Apr 28, 2025 pm 04:38 PM

PEAR is a PHP framework for reusable components, enhancing development with package management, coding standards, and community support.

What are the uses of PHP?What are the uses of PHP?Apr 28, 2025 pm 04:37 PM

PHP is a versatile scripting language used mainly for web development, creating dynamic pages, and can also be utilized for command-line scripting, desktop apps, and API development.

What was the old name of PHP?What was the old name of PHP?Apr 28, 2025 pm 04:36 PM

The article discusses PHP's evolution from "Personal Home Page Tools" in 1995 to "PHP: Hypertext Preprocessor" in 1998, reflecting its expanded use beyond personal websites.

How can you prevent session fixation attacks?How can you prevent session fixation attacks?Apr 28, 2025 am 12:25 AM

Effective methods to prevent session fixed attacks include: 1. Regenerate the session ID after the user logs in; 2. Use a secure session ID generation algorithm; 3. Implement the session timeout mechanism; 4. Encrypt session data using HTTPS. These measures can ensure that the application is indestructible when facing session fixed attacks.

How do you implement sessionless authentication?How do you implement sessionless authentication?Apr 28, 2025 am 12:24 AM

Implementing session-free authentication can be achieved by using JSONWebTokens (JWT), a token-based authentication system where all necessary information is stored in the token without server-side session storage. 1) Use JWT to generate and verify tokens, 2) Ensure that HTTPS is used to prevent tokens from being intercepted, 3) Securely store tokens on the client side, 4) Verify tokens on the server side to prevent tampering, 5) Implement token revocation mechanisms, such as using short-term access tokens and long-term refresh tokens.

What are some common security risks associated with PHP sessions?What are some common security risks associated with PHP sessions?Apr 28, 2025 am 12:24 AM

The security risks of PHP sessions mainly include session hijacking, session fixation, session prediction and session poisoning. 1. Session hijacking can be prevented by using HTTPS and protecting cookies. 2. Session fixation can be avoided by regenerating the session ID before the user logs in. 3. Session prediction needs to ensure the randomness and unpredictability of session IDs. 4. Session poisoning can be prevented by verifying and filtering session data.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software