使用ThinkPHP和Laravel等框架的都知道,所以的請求都需要經過index.php文件入口,無論你的URI是什么。
當然除了訪問的是靜態文件或者訪問路徑的文件真實存在,例如你訪問xxx.com/home/page.html
首先,web服務器先去更目錄找home文件夾下面的page.html,如果存在就訪問這個文件,如果不存在就重新URL,進入index.php大入口
當然,這一切都是規則制定的。請看下面的.htaccess文件【不記得怎么寫我教你,.ht+access 】
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule>
RewriteCond的 %{REQUEST_FILENAME} !-d 的意思是訪問的路徑不是一個目錄時RewriteRule才能生效
RewriteCond的 %{REQUEST_FILENAME} !-f 的意思是訪問的路徑不是一個文件時RewriteRule才能生效
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] 的意思是將訪問路徑重寫到index.php/的后面,最為參數傳遞給index.php文件
詳細的RewriteCond的規則請看這篇博文:http://blog.sina.com.cn/s/blog_545759110100h5g4.html
詳細的RewriteRule的規則請看這篇博文:http://blog.csdn.net/paulluo0739/article/details/17711851