2015-07-12 99 views
1

我的鏈接是改寫表格後,動態URL提交

search?c=category&s=product 

我已經刪除與htaccess的.php爲,一切從用戶的搜索,第一頁會顯示上面的鏈接工作分開,我想要顯示爲下面的鏈接:

search/category/product 

我嘗試下面的代碼:

Options +FollowSymLinks 
RewriteEngine on 

RewriteRule ^product/(.*)/(.*)/(.*) product.php?id=$1&c=$2&name=$3 

RewriteRule ^search/(.*)/(.*)/(.*) search.php?c=$1&s=$2&page=$3 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php 

RewriteCond %{THE_REQUEST} \ /+search\?c=([^&\ ]+)&s=([^&]+) 
RewriteRule^/search/%1/%2? [L,R] 

我是什麼想念g在上面?

+0

規則看起來不錯,你面臨什麼問題? – anubhava

+0

當他們在查詢類型,然後點擊搜索鏈接仍然顯示爲搜索?c =類別&S =產品 – user3312792

+0

這是哪裏htaccess的定位和它有其他的規則呢? – anubhava

回答

1

有規矩是這樣的:

Options +FollowSymLinks 
RewriteEngine on 
RewriteBase /site/ 

RewriteCond %{THE_REQUEST} /search\?c=([^&\s]+)&s=([^&\s]+) [NC] 
RewriteRule^search/%1/%2? [L,R] 

RewriteRule ^product/([^/]+)/([^/]+)/([^/]+)/?$ product.php?id=$1&c=$2&name=$3 [L,QSA] 

RewriteRule ^search/([^/]+)/([^/]+)/([^/]+)/?$ search.php?c=$1&s=$2&page=$3 [L,QSA] 

RewriteRule ^search/([^/]+)/([^/]+)/?$ search.php?c=$1&s=$2 [L,QSA] 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php [L] 
+0

這個固定的最後兩行倒是%20HTTP/1.1〜我的搜索查詢 – user3312792

+0

葉,這是正確的,但打破了第一頁的結果,因爲它需要頁面定義爲1個 – user3312792

+0

搜索/分類/產品/ l - 工程...搜索/分類/產品打破 – user3312792