我已經從我的工作有一個代碼點火項目工作,所以我試圖做到這一點了解了一些關於MVC:捕獲其間網址的所有實例/ /但如果文件
之前: 的index.php somepage.php secondpage.php
所有這些文件有「包括(頭),包括(頁腳)等等...
相反,我要捕捉的用戶是什麼頁面從url尋找 - >將它們重定向到索引,並且始終將頁眉和頁腳加載到該地方,唯一的變化就是內容。
所以我做了這個與我的htaccess:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule (.*)/(.*)/(.*)/(.*)/(.*)/(.*) index.php?page=$1&child=$2&grandchild=$3&cousin=$4&aunt=$5&uncle=$6 [NC,QSA,L]
RewriteRule (.*)/(.*)/(.*)/(.*)/(.*) index.php?page=$1&child=$2&grandchild=$3&cousin=$4&aunt=$5 [NC,QSA,L]
RewriteRule (.*)/(.*)/(.*)/(.*) index.php?page=$1&child=$2&grandchild=$3&cousin=$4 [NC,QSA,L]
RewriteRule (.*)/(.*)/(.*) index.php?page=$1&child=$2&grandchild=$3 [NC,QSA,L]
RewriteRule (.*)/(.*) index.php?page=$1&child=$2 [NC,QSA,L]
RewriteRule (.*^.css) index.php?page=$1 [NC,QSA,L]
</IfModule>
隨着心態,如果它的工作原理它是一個開始..但它不工作。首先我注意到我的CSS沒有加載..顯然-f沒有幫助,所以我添加了規則,但是/img/bg.png也不起作用。
我希望很明顯我正在嘗試捕獲url中//之間的任何單詞並將它們傳遞給索引作爲參數。你們知道是否有任何智能重寫規則,如果文件存在實際上忽略了重寫?
嗯這可能適用於不重寫內部調用:http://stackoverflow.com/questions/11116087/url-rewriting-doesnt-rewrite-automatically我會試試看! :D – Alisso 2013-04-09 19:43:38