Configure URL forwarding in Apache

Source: Internet
Author: User

The procedure is as follows:

1. Enable the Rewrite Environment

Edit the/etx/httpd/conf/http. conf file

Remove the # Above "# loadmodule rewrite_module modules/mod_rewrite.so #

2. You also need to authorize ". htaccess" in any directory and change "AllowOverride" to "All"

3. Enable RewriteEngine and set the value to "On". If there is no RewriteEngine, add a "RewriteEngine On"

4. You can set the default homepage of your site at this time.

Find <DIRECTORY> </DIRECTORY> and add the following content to the two labels:

# Enable php support

AddType application/x-http-php.php

When setting the homepage, I set index.htm and index. php here. Of course you can change it to another one, which is the red part.

DirectoryIndex index.htm

DirectoryIndex index. php

5. now enable URL redirection

I will use an example to illustrate that you can replace the red part with what you need.

URL forwarding

Find "RewriteEngine On"

Add

RewriteCond % {HTTP_HOST} ^ test.www.baidu.com [NC]

<# [NC] indicates the end. The above is the source address you want to forward.

RewriteRule ^ (. *) http://www.centoscn.com/test/test/#r,l]

# The last one is the destination address you forwarded. R indicates that the target address is displayed normally. If it is set to P, the target address is hidden.

6. Now you access ^ test.www.baidu.com will automatically jump to the http://www.centoscn.com/test/test/

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.