先開啓僞靜態。詳情查看這篇文章:http://www.cnblogs.com/CyLee/p/5544119.htmlphp
而後在項目根目錄中新建一個.htaccess文件,加入如下代碼css
正則中()的變量 == $1,$2,$3,$4...html
&%1是忽略、去掉不關注的字符串code
<ifmodule mod_rewrite.c>htm
RewriteEngine Onblog
RewriteRule ^css/(.*) /MVC/V/A001/css/$1
RewriteRule ^js/(.*) /MVC/V/A001/js/$1字符串
RewriteCond %{QUERY_STRING} ^(.*)
RewriteRule ^([a-zA-Z_]{2,10})/?$ /index.php?controller=$1&%1 get
RewriteCond %{QUERY_STRING} ^(.*)
RewriteRule ^([a-zA-Z_]{2,10})/([a-zA-Z_]{1,20})/?$ /index.php?controller=$1&action=$2&%1it
</ifmodule>io
當訪問shenyi.com/index/index/時,等同於訪問localhost:80/index.php?controller=index&action=index