PHP learning notes: Writing pseudo-static rules, php learning notes pseudo-static
Here we use Apache as the server software and use the case directly:
1. Redirect index.html to index. php
RewriteEngine OnOptions -IndexesReWriteRule ^index.html$ /index.php [NC]
Effect: the result of accessing www.test.com/index.htmlis www.test.com/index.php.
2. Redirect index to index. php
RewriteEngine OnOptions -IndexesReWriteRule ^index$ /index.php [NC]
Effect: Accessing www.test.com/indexeffect is equivalent to www.test.com/index.php.
3. php files in the root directory can be accessed with html suffixes
Statement 1:
RewriteEngine OnOptions -IndexesReWriteRule ^([a-zA-Z0-9_]{1,})\.html$ /$1.php [NC]
Effect: the result of accessing www.test.com/index.htmlis www.test.com/index.php.
Access www.test.com/abc.htmlresult is equivalent to www.test.com/abc.php
4. directly access the PHP file in the root directory with the same effect as the file name.
RewriteEngine OnOptions -IndexesReWriteRule ^([a-zA-Z0-9_]{1,})$ /$1.php [NC]
Effect: Accessing www.test.com/indexeffect is equivalent to www.test.com/index.php.
Accessing www.test.com/abceffect is equivalent to www.test.com/abc.php