Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Apache configure domain name 301 jump

Shulou Source: shulou.com Published: 2022-06-01 04:38:34 10月05日 Update

Configure domain name 301 jump

When there are two domain names, we need to set a primary domain name (jump the secondary domain name to the primary domain name). The operation command is as follows:

Vim / usr/local/apache2/conf/extra/httpd-vhosts.conf

Add the following line under # CustomLog "logs/dummy-host.example.com-access_log" common:

RewriteEngine on

RewriteCond% {HTTP_HOST} ^ www.aaa.com$

RewriteRule ^ / (. *) $http://www.test.com/%1 [Rust 301m L]

Save exit

# Redirect 301 permanent redirect domain name jump must use 301, which is good for the browser

Jump 302 indicates temporary redirection

Apachectl-M # observe whether the rewrite_module module is loaded

Apachectl-t

Apachectl restart

Curl-x192.168.1.113: 80 www.aaa.com/dsgsdgsdfg-I # test whether the domain name jumps normally

If there are more than two domain names, the operations are as follows:

Vim / usr/local/apache2/conf/extra/httpd-vhosts.conf

Add:

I

RewriteCond% {HTTP_HOST} ^ www.aaa.com$ [OR]

RewriteCond% {HTTP_HOST} ^ www.bbb.com$

Save exit

Apachectl-t

Apachectl restart

Curl-x 192.168.1.113: 80 www.bbb.com/asllsdfsf-I

Tags: Domain name two situation configuration one line command benefit module browser permanent test browse observe Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft vpn Linux macOS Shulou Tech Info