Home  >  Article  >  PHP Framework  >  How to configure domain name in thinkphp

How to configure domain name in thinkphp

藏色散人
藏色散人Original
2019-09-03 14:14:085323browse

How to configure domain name in thinkphp

How to configure a domain name in thinkphp?

Thinkphp5.1 Configure domain name (site) settings

1. First find D:\xampp\apache\conf\extra

httpd-vhosts.conf File

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "D:/xampp/htdocs/tp/public"
    ServerName tp
    ErrorLog "logs/dummy-host2.example.com-error.log"
    CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>

2. Modify it to:

How to configure domain name in thinkphp

##3. Find the

C:\Windows\System32\drivers\etc

hosts file again

4. Add at the bottom:

127.0.0.1 tp

Related recommendations: "

ThinkPHP Tutorial"

phpstydy local configuration domain name access method

This article mainly shares with you the phpstydy local configuration domain name access method, I hope it can help everyone.

1. hosts configuration:

1. Open the hosts file with an editor, location: C:\Windows\System32\drivers\etc directory

Example:

Add the following code at the end of the hosts file:

127.0.0.1 www.tp5.com

2. apache configuration:

1. Edit the httpd.conf file, open the virtual host, location: in the apache installation directory , that is, phpStudy\Apache\conf in the phpstudy installation directory, find Includeconf/extra/httpd-vhosts.conf, and remove the preceding

#2. Enter the opened virtual host file httpd-vhosts.conf to configure the domain name , Location: \phpStudy\Apache\conf\extra directory

Configuration rules:

ServerAdminwebmaster@dummy-host.example.com
DocumentRoot"D:/phpStudy/WWW/要配置域名的项目名"

ServerName configured domain name

ErrorLog"logs/dummy-host2.example.com-error.log"
CustomLog"logs/dummy-host2.example.com-access.log" common
</VirtualHost>

If you want to The entry file index.php is hidden in the Apache configuration. Even if the access address: localhost/h5.test.cn/index.php/test/index is simplified to localhost/h5.test.cn/test/index, it can also be achieved through domain name configuration. , that is, as follows:

DocumentRoot"D:/phpStudy/WWW/h5.test.cn"
ServerNamelocal.h5.test.cn
<IfModuledir_module>
DirectoryIndexindex.php
</IfModule>
</VirtualHost>

After the above configuration is completed, remember to restart the server.

Note: A problem arises at this time, that is, if you use localhost to access other local projects, you cannot access them. With so many projects, I don’t want to configure a virtual domain name for each one. It can be accessed by both domain name and localhost. I found a solution on the Internet:

Use the above method to add a domain name named localhost and bind it to the www directory, then comment out the ServerName localhost line in the httpd.conf file, restart apache, and then All can be accessed.

The above is the detailed content of How to configure domain name in thinkphp. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn