Apache2.4 开启Pathinfo 失败

我在谷歌中尝试了所有方法,但都失败了。

httpd.conf中的设置

<Directory "${SRVROOT}/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride None
    AcceptPathInfo On
    Require all granted
</Directory>

LoadModule dir_module modules/mod_dir.so


也设置了

php.ini中

cgi.fix_pathinfo=1

也设置了

phpinfo中

在tp6的public目录下的.htaccess中

<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L]
</IfModule>

都失败了。

在tp6中我无法访问

http://localhost:63342/homework1/public/index.php/index/showflower


我只能访问

http://localhost:63342/homework1/public/index.php?s=/index/showflower

请问有办法能正常打开pathinfo模式吗?或者把tp6的pathinfo访问模式关闭

 

access.log文件部分信息

127.0.0.1 - - [16/Jun/2021:12:10:47 +0800] "GET /test/public/static/picture/9010066_m.jpg HTTP/1.1" 200 18347
127.0.0.1 - - [16/Jun/2021:12:10:47 +0800] "GET /test/public/static/picture/9010702_m.jpg HTTP/1.1" 200 13395
127.0.0.1 - - [16/Jun/2021:12:10:47 +0800] "GET /test/public/static/picture/9010668_m.jpg HTTP/1.1" 200 22411
127.0.0.1 - - [16/Jun/2021:12:10:47 +0800] "GET /test/public/static/picture/9040002_m.jpg HTTP/1.1" 200 19491
127.0.0.1 - - [16/Jun/2021:12:10:47 +0800] "GET /test/public/static/picture/201152623373880165.jpg HTTP/1.1" 200 18224

error.log

[Wed Jun 16 12:09:28.792475 2021] [core:error] [pid 16716:tid 1924] (20024)The given path is misformatted or contained invalid characters: [client 127.0.0.1:18099] AH00127: Cannot map GET /homeworkInApache/public/index.php/index/.../public/static/image/ttel.jpg HTTP/1.1 to file, referer: http://billow.com/homeworkInApache/public/index.php/index/index.html
[Wed Jun 16 12:09:32.747007 2021] [core:alert] [pid 16716:tid 1948] [client 127.0.0.1:9899] D:/Program/wamp/apache/htdocs/homeworkInApache/app/.htaccess: Invalid command 'deny', perhaps misspelled or defined by a module not included in the server configuration
[Wed Jun 16 12:09:37.405597 2021] [core:error] [pid 16716:tid 1948] (20024)The given path is misformatted or contained invalid characters: [client 127.0.0.1:9899] AH00127: Cannot map GET /homeworkInApache/public/.../public/static/image/ttel.jpg HTTP/1.1 to file, referer: http://billow.com/homeworkInApache/public/index.php
[Wed Jun 16 12:09:40.868257 2021] [core:error] [pid 16716:tid 1948] (20024)The given path is misformatted or contained invalid characters: [client 127.0.0.1:9899] AH00127: Cannot map GET /homeworkInApache/public/index.php/index/.../public/static/image/ttel.jpg HTTP/1.1 to file, referer: http://billow.com/homeworkInApache/public/index.php/index/index.html
[Wed Jun 16 12:10:44.652662 2021] [core:alert] [pid 16716:tid 1924] [client 127.0.0.1:1024] D:/Program/wamp/apache/htdocs/test/app/.htaccess: Invalid command 'deny', perhaps misspelled or defined by a module not included in the server configuration
[Wed Jun 16 12:10:47.449908 2021] [core:error] [pid 16716:tid 1948] (20024)The given path is misformatted or contained invalid characters: [client 127.0.0.1:14208] AH00127: Cannot map GET /test/public/.../public/static/image/ttel.jpg HTTP/1.1 to file, referer: http://billow.com/test/public/index.php
[Wed Jun 16 12:10:49.268983 2021] [core:error] [pid 16716:tid 1952] (20024)The given path is misformatted or contained invalid characters: [client 127.0.0.1:1032] AH00127: Cannot map GET /test/public/index.php/index/.../public/static/image/ttel.jpg HTTP/1.1 to file, referer: http://billow.com/test/public/index.php/index/index.html

我的wamp根目录是没有log信息的,因为我是php,apache分开安装的,不是集成环境,这些log信息是在apache中的logs文件中找到的,其中没有phplog的信息,php的文件夹中好像也没找到log信息

是创建了一个控制器  index,里面有个方法 showflower ?

tp6中试试访问: http://localhost:63342/homework1/public/index/showflower

tp6 是有路由的,路由定义了吗?https://www.kancloud.cn/manual/thinkphp6_0/1037495

public目录下的.htaccess,改成这段:

<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

 

如果你的访问路径是:homework1/public/index.php/index/showflower

那你试试public目录下的.htaccess,改成这段:

<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On
 
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ homework1/public/index.php/$1 [QSA,PT,L]
</IfModule>

 

百度后发现,果然是php storm的问题,因为它访问页面的端口是其自己的端口,并不是apache服务的端口,把默认端口修改成apache服务的端口就解决了

我把项目文件放置在apache目录中的htdocs中,直接在网页中打开项目便可正常运行,但是我在php storm中打开该文件就不可以使用pathinfo模式访问路由,也就是说服务器和php配置应该是正常的,但是也不应该是编译器的问题吧...

您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps: 问答会员年卡【8折】购 ,限时加赠IT实体书,即可 享受50次 有问必答服务,了解详情>>>https://t.csdnimg.cn/RW5m