2012-07-24 122 views
0

我有一個網站www.domain.com/jeeves/。我想在網站上搜索如下所示:.htaccess搜索頁面重寫

http://www.domain.com/jeeves/results/[search_term_here]/[page_number_here] 

在搜索時,我希望他們轉到第1頁,當然。在nextprevious等,瀏覽頁碼。

的.htaccess:

# rewrite all URL's of the format I want to point at my php page with params 
RewriteRule ^results/([A-Za-z0-9]+)$/([0-9]+)$ http://www.domain.com/jeeves/search.php?s=$1&page=$2 [NC,L] 

# rewrite initial search query to the first page of results 
RewriteCond %{QUERY_STRING} s=([^&]*) 
RewriteRule ^search http://www.domain.com/jeeves/results/%1/1? [NC,R=301] 

這似乎並不工作 - 任何人都可以幫忙嗎?

回答

1

您有不正確的正則表達式第一:^結果/([A-ZA-Z0-9] +)$ /([0-9] +)$
試試這個:

RewriteRule ^jeeves/results/([A-Za-z0-9]+)/([0-9]+)/?$ /jeeves/search.php?s=$1&page=$2 [NC,L] 
RewriteCond %{QUERY_STRING} s=([^&]+) 
RewriteRule ^jeeves/search /jeeves/results/%1/1? [NC,R=301]`enter code here`