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

可以通过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就可以了。

转载于:https://www.cnblogs.com/aaronguo/p/11164080.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值