Blogger Information
Blog 17
fans 0
comment 0
visits 23126
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
thinkphp5配置入口路径
飞鸿先森的博客
Original
1031 people have browsed it

在使用thinkphp5框架开发的项目当中,默认的访问路径格式一般都带有public/index.php,即使是访问网站主页,也得加上public才可以,但这是很不友好的,就且论用户体验来说,人家申请了一个域名,访问网站的时候不可能让人写了域名在加上public/index.php吧。在此之前我在网上查阅过很多资料,都没能帮我彻底的问题,最后摸索出解决办法如下:

所用服务器工具:phpStudy(WAMPServer也一样)

首先打开配置文件httpd-vhosts-conf,然后修改网站根目录到public文件夹

<VirtualHost *:80>

    ServerName localhost

    DocumentRoot "d:/wampserver/wamp64/www/public"

    <Directory  "d:/wampserver/wamp64/www/public/">

        Options +Indexes +Includes +FollowSymLinks +MultiViews

        AllowOverride All

        Require local

    </Directory>

</VirtualHost>

然后修改thinkphp框架里面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>

修改为如下:

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

其实就增加了一个字符,在倒数第二行的index.php后面加了个?,即可实现网站入口问件的修改。

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post