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

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

你可能感兴趣的:(thinkphp)