2010-07-13 43 views
1

之一如果從project_name開始在條件重寫規則 - 如何申請只有這兩套規則

http://project_name/browse_by_exam/type/classes/... 
http://project_name/my_study_centre/page_sort/1,20,name,asc/... 

然後應用這條規則的第一個位置browse_by_exammy_study_centre: -

RewriteRule ^([a-zA-Z0-9\-\_]+)/?$ index.php?a=$1 
RewriteRule ^([a-z0-9\-\_]+)/([a-z0-9\-\_]+)/?$ index.php?a=$1&b=$2 

對於其他所有網址應用這些規則: -

RewriteCond $1 !^(index\.php|resources|robots\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php [L,QSA] 

謝謝,

Sandeepan這些URL

+0

@skaffman我覺得我申請有意義的標籤,你爲什麼要刪除這些? – 2010-07-13 14:35:50

+0

因爲這是一個關於mod-rewrite的問題,那就是人們要查找的標籤。標籤有分類,而不是描述。 – skaffman 2010-07-13 14:50:39

回答

1

我自己找到了解決方案。以下工作: -

############Following rules apply only to browse_by_exam and my_study_centre 

RewriteCond $1 !^(index\.php|resources|robots\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond $1 ^(browse_by_exam|my_study_centre) 

RewriteRule ^(.*)$ index.php [L,QSA] 
################################################# 


###Following rules apply to all other pages (other than browse_by_exam and my_study_centre) 
RewriteRule ^([a-zA-Z0-9\-\_]+)/?$ index.php?a=$1 

RewriteRule ^([a-z0-9\-\_]+)/([a-z0-9\-\_]+)/?$ index.php?a=$1&b=$2 

RewriteRule ^([a-z0-9\-\_]+)/([a-z0-9\-\_]+)/([a-zA-Z0-9\-\_+]+)/?$ index.php?a=$1&b=$2&c=$3 

RewriteRule ^([a-z0-9\-\_]+)/([a-z0-9\-\_]+)/([a-zA-Z0-9\-\_+]+)/([0-9]+)/?$ index.php?a=$1&b=$2&c=$3&d=$4 

乾杯,

Sandeepan

0

均未被你的兩個規則的模式匹配。但是如果你想編寫符合你的條件的規則,試試這樣的規則:

RewriteRule ^(browse_by_exam|my_study_centre)($|/) foobar [L] 
+0

謝謝你的回答,但我不清楚它......如果你可以用我的例子顯示.. – 2010-07-14 05:48:29