首页 > Web开发 > 详细

linux服务器中Apache隐藏index.php失败

时间:2019-07-10 15:25:17      阅读:102      评论:0      收藏:0      [点我收藏+]

可以通过URL重写隐藏应用的入口文件index.php,下面是相关服务器的配置参考:

【Apache】

  1. httpd.conf配置文件中加载了mod_rewrite.so模块
  2. AllowOverride None 将None改为 All (PS:所有的AllowOverride对应的None都改为ALL)
  3. 把下面的内容保存为.htaccess文件放到应用入口文件的同级目录下

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
#如果页面出现"No input file specified." 请注释第一条,启用第二条
RewriteRule ^(.*)$ $1.php [QSA,PT,L]
#RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
#RewriteRule ^(.*)$ index.php [E=PATH_INFO:$1,QSA,PT,L] 
</IfModule>

以上操作全部都完成,重启apache后还是失败,原因在与include的【httpd-vhosts.conf】中配置没有改成允许URL重写。

只需将

DocumentRoot "F:/wamp/www/test"

ServerName www.test.com

ServerAlias admin.tpshop.com

DirectoryIndex index.html index.htm index.php

Options FollowSymLinks

AllowOverride none

Order allow,deny

Allow from all

改成

DocumentRoot "F:/wamp/www/test"

ServerName www.test.com

ServerAlias admin.tpshop.com

DirectoryIndex index.html index.htm index.php

Options FollowSymLinks

AllowOverride All

Order allow,deny

Allow from all

然后保存,重启apache就可以了。

linux服务器中Apache隐藏index.php失败

原文:https://www.cnblogs.com/aaronguo/p/11164080.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!