Configuration of apache second-level domain names in windows

Source: Internet
Author: User
Tags apache error log

Let's summarize the configuration of apache's second-level domain name in windows.

Next we will use the local 127.0.0.1 for testing

Here we take www.jobs.com as an example. In the following code, jobs.com can be replaced with the domain name you want. This is just for testing.

Our goal is that different subdomain names can access websites under different directories.:

 

1. Enable the mod_rewrite function of apache (it must support rewriting). In httpd. conf, just find the # in front of it,

Then, enable the apache Virtual Host and locate the previous # in httpd. conf.

 

2. Add several domain names. In the C: \ WINDOWS \ system32 \ drivers \ etc directory, find the hosts file notepad to open it and add the following three domain names.

127.0.0.1 www.jobs.com
127.0.0.1 jobs.com
127.0.0.1 news.jobs.com

 

3. Enter the relevant code in the VM to allow it to access the www directory, find the file in the directory Apache2 \ conf \ extra, and open the code to add the following

 

 

Then, bind www.jobs.com to the directory where the relevant jobs project is located and add the following code:

 

 

 

After the restart, restart apache. If an apache startup error occurs after the restart, view the apache Error Log and modify the log as needed.

 

4. Create a file in the jobs directory and add the following code to it:

 


I want to bind news.jobs.com to the new directory, so not only do I need to place the. htaccess file in the root directory,

You also need to place the. htaccess file in the new directory. The. htaccess file in the new directory is written as follows:

RewriteEngine On
RewriteBase/
RewriteCond % {REQUEST_FILENAME }! -F
RewriteCond % {REQUEST_FILENAME }! -D
ErrorDocument 403/404 .htm
ErrorDocument 404/404 .htm

 

After everything is done, you can try www.jobs.com job.com news.jobs.com and other accesses to see the expected results.

If you need access from other second-level domain names, repeat steps 2 and 4 in the preceding method. You do not need to restart apache.

 

 

This article only applies to the test environment and verifies the security. Please use it in the product after everything is set.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.