Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Configuration of Virtual Host virtual host and description of rewrite parameters in Apache

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the configuration of Virtual Host virtual host in Apache and the description of important parameters in rewrite module, which is the basic method of deploying multiple sites on the same Apache server software. Friends who need it can refer to it.

Virtual Host configuration process

In this example, our path is like this

DocumentRoot: / home/jb51 / sites/demo.jb51.net

ServerName:demo.jb51.net

1. Enter the apache virtual host settings directory

Cd / etc/apache2/sites-available

two。 Create a file demo.jb51.net

ServerAdmin webmaster@localhost DirectoryIndex index.html index.php DocumentRoot / home/jb51 / sites/demo.jb51.net ServerName demo.jb51.net ServerAlias demo.jb51.net allow from all Options + Indexes

3. Activate virtual host configuration

Sudo a2ensite demo.jb51.net

4. Enter the / etc/apache2/sites-enabled/ directory to view all active virtual hosts. You can log out with sudo a2dissite demo.jb51.net

Cd / etc/apache2/sites-enabled ls-lt

Display

The copy code is as follows:

Lrwxrwxrwx 1 root root 36 2013-04-05 17:29 demo.jb51.net->.. / sites-available/demo.jb51.net

5. Restart the apache service

Sudo / etc/init.d/apache2 restart

6.ubuntu sets host

Vim / etc/hosts

127.0.0.1 demo.jb51.net

7. Set to enable .htaccess and display directory structure list

AllowOverride none AllowOverride all Options-Indexes FollowSymLinks

AllowOverride none means to disable .htaccess. If you want to enable it, set it to AllowOverride all.

Options-Indexes means to disable the display of directory structure. If you want to enable it, set it to Options Indexes.

Options FollowSymLinks supports symbol link (soft connection). If you want to close it, you can set it to Options-FollowSymLinks.

Description of important parameters of rewrite module

Enable rewrite:

Sudo a2enmod rewrite

Deactivate rewrite:

Sudo a2dismod rewrite

Server environment variables: the environment variables provided by Apache to the rewirte module are roughly divided into five types.

Part one: some parameters of HTTP headers

1. Parameter name: HTTP_USER_AGENT

Sample reference value: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8

Description: equivalent to the server parameter in PHP: $_ SERVER ["HTTP_USER_AGENT"]

two。 Parameter name: HTTP_REFERER

Sample reference value: http://www.test.cn/test.php

Description: equivalent to the server parameter in PHP: _ SERVER ["HTTP_REFERER"]

3. Parameter name: HTTP_COOKIE

Sample reference value: ZDEDebuggerPresent=php,phtml,php3

Description: equivalent to the server parameter in PHP: $_ SERVER ["HTTP_COOKIE"]

4. Parameter name: HTTP_FORWARDED

Sample reference value: if you use a proxy server, it will be the IP address of the proxy server, so it is not easy to test the value locally.

Description: equivalent to the server parameter in PHP: $_ SERVER ["HTTP_FORWARDED"]

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report