2010-03-02 71 views
3

我的客戶端一直在編輯網站導航的結構,這導致了一些mod_rewrite問題。我怎麼能這個規則:mod_rewrite規則:如果URL包含某個字符串

RewriteRule ^studios/about-studios/artist-noticeboard noticeboard2.php?section=studios&subSection=studio-artists [L] 

如果該網址包含"noticeboard"?像這樣:

RewriteRule ^IF CONTAINS 'noticeboard' noticeboard2.php?section=studios&subSection=studio-artists [L] 

任何指針歡迎!

回答

8

試試這個:

RewriteCond %{REQUEST_URI} !/noticeboard2\.php$ 
RewriteRule noticeboard noticeboard2.php?section=studios&subSection=studio-artists [L] 

此規則將改寫包含在同一目錄下的URL路徑noticeboard2.php「布告欄」的任何請求。

+0

快速工作! thanx秋葵。 – v3nt 2010-03-02 13:03:00

+0

如果我不想重寫id url,我需要指定什麼包含布告欄 – Sergey 2012-09-04 08:01:37

+1

@Sergey用'!'反轉'RewriteRule'模式。 – Gumbo 2012-09-04 18:59:52

相關問題