Web site Construction, will usually use the site address URL redirection, this advantage is conducive to your site SEO optimization, that is, to make your site pseudo-static, the following is a brief introduction to the implementation of the two ways:
1. Setting redirects in the Apache configuration file
First locate the Apache configuration file httpd.conf, locate the following code in the configuration file LoadModule rewrite_module modules/mod_rewrite.so, open it (that is, remove the previous #).
Then open the output phpinfo () function, if the Mod_rewrite module is turned on in the module, the above step is successful, such as
Then configure the URL rules, if you do not configure Apache virtual host, please see the following article
Wamp Configuration of the development environment Apache Virtual host
Locate the Apache config Virtual host file httpd-vhosts.conf, and under the label, write the
Rewriteengine on
Rewritebase/
Rewriterule index.php test.php
Note: (1) you want to configure which virtual host URL redirection is written under the tag of which virtual host
(2) Rewritebase refers to the directory of your test.php files, or the root directory of the site, if you test.php under the A folder, write/a/
(3) Rewriterule means matching rules, here means that when the user enters the index.php page, automatically jumps to the test.php page, but the URL meaning is index.php
2. URL redirection via . htaccess File
The first step is to open the Mod_rewrite module, the second step in the Apache configuration file to find the label, under this tab to change allowoverride None to allowoverride all
Then create. htaccess (secretly tell you, this read h-t-access, do not thank me oh), because window does not allow files without file name, so we can create. htaccess file
Open Notepad, click Save As, note that the encoding is ANSI, and sometimes the. htaccess file may fail because the file is not encoded
The following is written in the. htaccess file, with the same content written in the first way
3.URL Redirection Considerations
First, for example, if I want to redirect index/,blog/to index.php,blog.php, I can write this
Then when we've defined the rules in the. htaccess, it is important to note that the path to the JS, CSS, image, and so on of our original site may be wrong, because when he takes your site's address as index/, the browser will think that you are in the index folder, All will be in the index folder to find your CSS, JS, image, etc., all will be wrong. The workaround is to use the absolute path, which is to precede your path with a/symbol to start searching for this file from the root directory of the site!