例如,在客户的角度来看,我希望CreateAccount.php
显示为http://www.example.com/CreateAccount/
。我知道创建很多目录并用index.php
填充每个目录很容易,但是我宁愿做最有效的事情。首先,使用该方法将需要高度无组织且不必要复杂的组织标准。其次,我也宁愿充分利用Apache的功能,即mod_rewrite
。
我知道有mod_rewrite
。我已经开始阅读该模块的文档,但是由于我有ADHD,我很快就变得困惑[
<IfModule mod_rewrite.c>
RewriteEngine On
# You can use this only inside of the Directory directive or in the .htaccess file.
RewriteBase /
# http://www.example.com/page.html to redirect to http://www.example.com/page.php
RewriteRule ^(.*).html /$1.php [L]
# http://www.example.com/mypath/page.html to redirect to http://www.example.com/mypath/page.php
RewriteRule ^mypath/(.*).html /mypath/$1.php [L]
# http://www.example.com/CreateAccount/ to redirect to http://www.example.com/CreateAccount.php
RewriteRule ^(.*)/ /$1.php [L]
</IfModule>