一、首先配置xampp的httpd-vhosts.conf 文件

打开xampp的安装目录,找到 apache\conf\extra 路径下的 httpd-vhosts.conf 文件

打开注释 NameVirtualHost *:80
这句很重要,我就是忘记打开它,结果无论host里配置的什么网址都指向htdoc的根目录
添加站点配置:

<VirtualHost *:80>
    ServerAdmin yang@21cn.com
    DocumentRoot "C:/xampp/htdocs/"
    ServerName localhost
    ServerAlias localhost
    ErrorLog "logs/localhost-error.log"
    ##=====注意此处是相对地址,有网上是绝对地址的,配置后appach启动不起来
    CustomLog "logs/localhost-access.log" combined
    <Directory "C:/xampp/htdocs/">
        Options Indexes FollowSymLinks
        AllowOverride all
        Order Allow,Deny
        Allow from all
    </Directory>
</VirtualHost>

 

修改后,保存 httpd-vhosts.conf 文件,并重启Apache。

二、然后修改本机Host文件

然后我们来修改Host文件
文件所在位置 C:\WINDOWS\system32\drivers\etc\hosts
在后面添加:

127.0.0.1     v2011.app.com 
192.168.0.206 yang.com

 

三、再隐藏TP5入口文件

在ThinkPHP5.0中,出于优化的URL访问原则,还支持通过URL重写隐藏入口文件,下面以Apache为例说明隐藏应用入口文件index.php的设置。

下面是Apache的配置过程,可以参考下:
1、httpd.conf配置文件中加载了mod_rewrite.so模块
2、AllowOverride None 将None改为 All
3、在应用入口文件同级目录添加.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>

 

posted on 2020-05-22 10:02  宇宙神奇  阅读(462)  评论(0编辑  收藏  举报