Nginx 服务动态 php 页面

Nginx serving dynamic php page

提问人:AntDeMu 提问时间:5/31/2019 最后编辑:marc_sAntDeMu 更新时间:6/1/2019 访问量:129

问:

我正在尝试将所有公司服务器切换到nginx。到目前为止,一切都很顺利,除了我们像电子商务一样使用的门户网站。

第一个问题是,该门户是由外部公司(通信公司)制作的,因此我没有真正记录在架构上。

Web 门户的主页是一个动态构建所有其他页面的 php 页面:有一个很长的切换案例,在每种情况下都有一个包含页面N.php

例。。。

case "logout":
include ("shop/logout.php");
exit;

现在问题来了,当我单击注销(或所有其他按钮)时,传递的 URL 是一个 xhtml(从 www.site.com/index.php 到 www.site.com/aris.xhtml),nginx 返回 404。aris.xhtml 在文件系统中不存在,我认为它是自动生成的。

我已经测试了不同的配置,但我能得到的最好的结果是相同的索引页面,也单击按钮(没有提供页面,但没有 404)。

有人可以向我解释这种类型的 Web 架构,或者向我指出文档?

提前致谢

.htaccess文件包含以下内容:

#####################################################
# Script: htaccess Security                 #
# Version: 1.0                                      # 
#####################################################

# No web server version and indexes
ServerSignature Off
Options -Indexes

# Enable rewrite engine
RewriteEngine On

# Exclude ipn
#RewriteRule ^(ipn)($|/) - [L]
RewriteRule ^ipn/.*$ - [PT]

# Block suspicious request methods
RewriteCond %{REQUEST_METHOD} ^(HEAD|TRACE|DELETE|TRACK|DEBUG) [NC]
RewriteRule ^(.*)$ - [F,L]

# Block WP timthumb hack
RewriteCond %{REQUEST_URI} (timthumb\.php|phpthumb\.php|thumb\.php|thumbs\.php) [NC]
RewriteRule . - [S=1]

# Block suspicious user agents and requests
RewriteCond %{HTTP_USER_AGENT} (libwww-perl|wget|python|nikto|curl|scan|java|winhttp|clshttp|loader) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (<|>|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (;|<|>|'|"|\)|\(|%0A|%0D|%22|%27|%28|%3C|%3E|%00).*(libwww-perl|wget|python|nikto|curl|scan|java|winhttp|HTTrack|clshttp|archiver|loader|email|harvest|extract|grab|miner) [NC,OR]
RewriteCond %{THE_REQUEST} \?\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} \/\*\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} etc/passwd [NC,OR]
RewriteCond %{THE_REQUEST} cgi-bin [NC,OR]
RewriteCond %{THE_REQUEST} (%0A|%0D) [NC,OR]
# Block MySQL injections, RFI, base64, etc.
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=http:// [OR]
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=(\.\.//?)+ [OR]
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=/([a-z0-9_.]//?)+ [NC,OR]
RewriteCond %{QUERY_STRING} \=PHP[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} [NC,OR]
RewriteCond %{QUERY_STRING} (\.\./|\.\.) [OR]
RewriteCond %{QUERY_STRING} ftp\: [NC,OR]
RewriteCond %{QUERY_STRING} http\: [NC,OR]
RewriteCond %{QUERY_STRING} https\: [NC,OR]
RewriteCond %{QUERY_STRING} \=\|w\| [NC,OR]
RewriteCond %{QUERY_STRING} ^(.*)/self/(.*)$ [NC,OR]
RewriteCond %{QUERY_STRING} ^(.*)cPath=http://(.*)$ [NC,OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*iframe.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^i]*i)+frame.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [NC,OR]
RewriteCond %{QUERY_STRING} base64_(en|de)code[^(]*\([^)]*\) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} ^.*(\[|\]|\(|\)|<|>).* [NC,OR]
RewriteCond %{QUERY_STRING} (NULL|OUTFILE|LOAD_FILE) [OR]
RewriteCond %{QUERY_STRING} (\./|\../|\.../)+(motd|etc|bin) [NC,OR]
RewriteCond %{QUERY_STRING} (localhost|loopback|127\.0\.0\.1) [NC,OR]
#RewriteCond %{QUERY_STRING} (<|>|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]
RewriteCond %{QUERY_STRING} concat[^\(]*\( [NC,OR]
RewriteCond %{QUERY_STRING} union([^s]*s)+elect [NC,OR]
RewriteCond %{QUERY_STRING} union([^a]*a)+ll([^s]*s)+elect [NC,OR]
RewriteCond %{QUERY_STRING} (;|<|>|'|"|\)|%0A|%0D|%22|%27|%3C|%3E|%00).*(/\*|union|select|insert|drop|delete|update|cast|create|char|convert|alter|declare|order|script|set|md5|benchmark|encode) [NC,OR]
RewriteCond %{QUERY_STRING} (sp_executesql) [NC]
RewriteRule ^(.*)$ - [F,L]

# Deny browser access to config files
#Order allow,deny
#Deny from all
#Allow from 1.2.3.4




<IfModule mod_rewrite.c>

RewriteEngine On
#RewriteCond %{SERVER_PORT} 80
#RewriteRule ^(.*)$ http://octo.web.site.it/$1 [R,L]
RewriteBase /

RewriteCond %{QUERY_STRING} ^(.*)$


#  cod + cat + cat2 + id
RewriteRule ^(.*)\/(.*)\/(.*)\/([0-9]*)_(.*).xhtml$ index.php?cod=$1&cat=$2&cat2=$3&id=$4&%1 [L,QSA]
RewriteRule ^(.*)\/(.*)\/(.*)\/(.*)_([0-9]*).xhtml$ index.php?cod=$1&cat=$2&cat2=$3&id=$5&%1 [L,QSA]
RewriteRule ^(.*)\/(.*)\/(.*)\/(.*).xhtml$ index.php?cod=$1&cat=$2&cat2=$3&id=$4&%1 [L,QSA]

#cod + cat + cat2
RewriteRule ^(.*)\/([0-9]*)_(.*)\/([0-9]*)_(.*).xhtml$ index.php?cod=$1&cat=$2&cat2=$4%1 [L,QSA]
RewriteRule ^(.*)\/(.*)_([0-9]*)\/(.*)_([0-9]*).xhtml$ index.php?cod=$1&cat=$3&cat2=$5%1 [L,QSA]
RewriteRule ^(.*)\/(.*)\/(.*).xhtml$ index.php?cod=$1&cat=$2&cat2=$3&%1 [L,QSA]

# cod + id
RewriteRule ^(.*)\/([0-9]*)_(.*).xhtml$ index.php?cod=$1&id=$2&%1 [L,QSA]
RewriteRule ^(.*)\/(.*)_([0-9]*).xhtml$ index.php?cod=$1&id=$3&%1 [L,QSA]
RewriteRule ^(.*)\/(.*).xhtml$ index.php?cod=$1&id=$2&%1 [L,QSA]


# solo cod
RewriteRule ^(.*)_(.*).xhtml$ index.php?cod=$1&%1 [L,QSA]
RewriteRule ^(.*).xhtml$ index.php?cod=$1&%1 [L,QSA]
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

php nginx 动态 xhtml

评论

0赞 Sergiu Paraschiv 5/31/2019
您正在从 Apache HTTPD 切换?如果是,那么应用程序是否有 .htaccess 文件?这就是 URL 重写发生的地方。发布它,也许有人可以帮助你将这些规则翻译成nginx理解的东西。
0赞 AntDeMu 5/31/2019
谢谢Sergiu Paraschiv,你让我大开眼界!

答: 暂无答案