您的位置:首页 > 编程语言 > PHP开发

tp6框架访问目录影藏入口文件

2020-07-14 06:29 796 查看

打开apache安装目录中的httpd.confg,修改以下内容:

开启以下扩展:LoadModule rewrite_module modules/mod_rewrite.so

在Directory标签中,将AllowOverride none 设置为AllowOverride All

重启apache

将.htacess内容修改为以下内容:

<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>

如果你是使用WAMP搭建的环境,那么不需要修改.htacess,而是需要httpd-vhost.conf文件中修改规则,如下所示。

<VirtualHost *:80>
//开启重写
RewriteEngine on

RewriteCond $1 !^(index\.php|\/public)
////重写规则:可以不需要输入index.php来进行访问
RewriteRule ^(.*)$ /index.php/$1 [L]

DocumentRoot "E:/phpstudy/WWW/tp6/tp/public"
ServerName www.test.com
ServerAlias
FcgidInitialEnv PHPRC "E:/phpstudy/Extensions/php/php7.3.4nts"
AddHandler fcgid-script .php
FcgidWrapper "E:/phpstudy/Extensions/php/php7.3.4nts/php-cgi.exe" .php
ErrorLog "E:/phpstudy/Extensions/Apache2.4.39/logs/www.test.com_error.log"
CustomLog "E:/phpstudy/Extensions/Apache2.4.39/logs/www.test.com_acess.log" common
<Directory "E:/phpstudy/WWW/tp6/tp/public">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
DirectoryIndex index.php index.html error/index.html
</Directory>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: