Home >Backend Development >PHP Tutorial >How to configure virtual directory in php under windows
1. First find the apache configuration file httpd.conf and find the following code:
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
Remove # Include conf/extra/httpd-vhosts.conf# No., as follows:
Include conf/extra/httpd-vhosts.conf
Save.
2. Open the httpd-vhosts.conf file in the extra folder in Apache's conf directory, open it with Notepad, and add the following code at the end:
<span> 1</span> <VirtualHost *:80> <span> 2</span> ServerName www.mydemo.<span>com </span><span> 3</span> DocumentRoot "D:/mydemo" <span> 4</span> <Directory "D:/mydemo"> <span> 5</span><span>Options FollowSymLinks IncludesNOEXEC Indexes </span><span> 6</span> DirectoryIndex index.html index.htm <span>default</span>.htm index.php <span>default</span>.php index.cgi <span>default</span>.cgi index.pl <span>default</span>.pl index.<span>shtml </span><span> 7</span><span>AllowOverride Options FileInfo </span><span> 8</span> Order Deny,<span>Allow </span><span> 9</span><span>Allow from all </span><span>10</span> </Directory> <span>11</span> </VirtualHost>
3. Go to C:->Windows- >System32->drivers->etc directory, open the hosts file.
Add the following code at the end:
1 127.0.0.1 www.mydemo.com
Then create the D: mydemo directory
Then restart the apache server.
Enter www.mydemo.com in the browser to take a look
The above introduces the method of configuring a virtual directory in PHP under Windows, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.