Apache Rewrite experience

Source: Internet
Author: User

Apache Rewrite experience

Recently, the company wants to transfer servers. Dozens of websites are running on the servers. During the transfer, services are not affected. Therefore, Apache mod_rewrite is used for some processing.
The general environment is like this. The server has the site [1-50] .TA.com domain name and site [1-50] .TB.com domain name. Before you start to transfer the server, first, point site [1-50] .TB.com to the new server IP address. At the same time, run Apache on the new IP address and write the access Rewrite of siteX.TB.com back to TA.com. After one day, resolve TB.com to the new IP address, transfer the database and WEB service to the new IP address, and write the Apache Rewrite on the original server to SiteX.TB.com. Some users cache the DNS, as a result, the original server is still accessed.

The Rewrite statement is roughly as follows:

Copy codeThe Code is as follows: # Load mod_rewrite
LoadModule rewrite_module modules/mod_rewrite.so

# Enable mod_rewrite
RewriteEngine On
# Enable Log (for debugging)
RewriteLog "logs/rewrite. log"
RewriteLogLevel 9
# Only Rewrite the domain names starting with siteX, demo, and support
RewriteCond % {SERVER_NAME} ^ (site | demo | support) [NC]
# Add the host name before the URI
RewriteRule ^ (. +) % {SERVER_NAME} $1 [C]
# Convert all xxx.ta.com/#on this server to xxx.tb.com /*
RewriteRule ^ [a-z0-9] + )\. ([0-9a-z \.] + )/(. *) http: // $1 \. TB \. com/$3 [NC, R, L]

If Apache is configured with a virtual host, this configuration should be written to the default virtual host configuration.

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.