The procedure is as follows: 1. enable Rewrite environment editing/etx/httpd/conf/http. remove #2 in front of "# loadmodulerewrite_modulemodules/mod_rewrite.so" in the conf file. you also need to allow ". change "AllowOverride" to "All" 3. open
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 , Add the following content to the two tags:
# 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/