【问题标题】:Finding the php file which is executed (the name is hidden by .htaccess)查找执行的 php 文件(名称被 .htaccess 隐藏)
【发布时间】:2015-12-07 03:35:08
【问题描述】:

我在自己的网站上遇到了一个非常奇怪的情况。

当我尝试执行此页面时: http://www.****.com/Militari/Guida-scelta-.htm 或者这个页面 http://www.****.com/Militari/Guida-.htm

我得到相同的结果。查看 .htaccess/PHP 文件,这是一个完全不可预测的结果。

看起来执行的 php 文件是否会进行数据库搜索并尝试找到最佳匹配结果。

这是在共享主机上。 如何找到正在执行的 PHP 文件?

.htaccess

RewriteEngine on 
RewriteRule ^Cinema/Interviste/([^/]*)\.htm$ /Cinema/Interviste/film.php?title=$1
RewriteRule ^Cinema/dvd/([^/]*)\.htm$ /Cinema/dvd/film.php?title=$1
RewriteRule ^Cinema/([^/]*)\.htm$ /Cinema/film.php?title=$1
RewriteRule ^Attori/(.*)\.htm$ Attore.php?name=$1
RewriteRule ^Registi/(.*)\.htm$ Regista.php?regia=$1
RewriteRule ^(.*)\.htm $1\.php
RewriteRule filmrecensiti\.xml filmrecensiti\.xml\.php
RewriteRule filmrecensiti2\.xml filmrecensiti2_old\.xml
RewriteRule ^Elenco\sFilm\s(.)\.php Elenco_Film_Recensiti\.php?starting_letter=$1
RewriteRule ^Elenco\sFilm\sRecensiti(.*) Elenco_Film_Recensiti$1
RewriteRule ^(.*)\.js php_js\.php\?id=$1\.js
RewriteRule ^(.*)\.css php_css\.php\?id=$1\.css
#RewriteRule ^feeds/(.+)$ feeds_items/$1 [L]
ErrorDocument 400 /not_found.htm
ErrorDocument 401 /not_found.htm
ErrorDocument 403 /not_found.htm
ErrorDocument 404 /not_found.htm
ErrorDocument 500 /not_found.htm

编辑

我错过了子文件夹中的 .htaccess

它的内容是

RewriteRule ^([^/]*)\.htm$ film.php?title=$1

感谢您的建议,我找到了问题。

这很有帮助:$_SERVER['PHP_SELF']$_SERVER['SCRIPT_NAME']

【问题讨论】:

  • 您没有提供足够的信息让我们理解您的问题。也许发布您的 .htaccess 文件会有所帮助。
  • 这是您的网站还是其他人的网站?此外,它应该像重写规则一样可以加载到.htaccess 文件中。请张贴文件。此外,如果这是您的网站,您是否使用任何 PHP 框架?可能还有MVC风格的框架?...
  • 不,我没有使用任何框架..
  • 您是在 PHP 中寻找 $_SERVER['PHP_SELF'] 还是 $_SERVER['SCRIPT_NAME']
  • 注释掉这一行RewriteRule ^(.*)\.htm $1\.php并重新测试。

标签: php .htaccess lamp


【解决方案1】:

根据您发布的内容,唯一适用的规则是 RewriteRule ^(.*)\.htm $1\.php,这表明 http://www.****.com/Militari/Guida-scelta-.htm 实际上会提供 http://www.****.com/Militari/Guida-scelta-.php

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-06
    • 2013-08-02
    相关资源
    最近更新 更多