2012-07-06 68 views
0

我已經在.htaccess地址設置重寫 所有工作只是我的搜索功能停止如何使工作搜索功能的.htaccess URL重寫停止我的搜索功能

我的搜索網址是這個

http://domain.com/index.php?a=search&q=word 

但提交後搜索框url這個而不工作

http://www.domain.com/?a=search&q=word 

我該如何讓搜索框工作? 我htaccess文件

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^www.domain.com 
RewriteRule (.*) http://domain.com/$1 [R=301,L] 
RewriteCond %{request_filename} -f 
RewriteRule ^(.*) $1 [L] 
RewriteRule ^([^/]*)$ /index.php?a=$1 [L] 
RewriteRule ^([^/]*)/([^/]*)$ /index.php?a=$1&q=$2&page=$3 [L] 
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /index.php?a=$1&q=$2&page=$3 [L] 

我的搜索形式

<form class="form-wrapper cf"> 
<form accept-charset="UTF-8" action="http://www.domain.com/index.php" method="get"> 
<input name="a" type="hidden" value="search" /> 
     <input type="text" id="search" name="q" placeholder="Search here..." required> 
     <button type="submit">Search</button> 
</form> 

感謝

+0

如果您將所有對「www.domain.com」的請求重定向到「domain.com」,爲什麼您的搜索表單的操作爲「http:// www.domain.com/index.php」?爲什麼不移除www以避免重定向? – 2012-07-06 06:32:03

+0

我已經設置了表單的動作/index.php,也沒有www,但不工作 – Hemang 2012-07-06 06:48:05

回答

0

我被變化的解決方案

<form class="form-wrapper cf"> 
<form accept-charset="UTF-8" action="/index.php" method="get"> 
<input name="a" type="hidden" value="search" /> 
     <input type="text" id="search" name="q" placeholder="Search here..." required> 
     <button type="submit">Search</button> 
</form> 

變化對

<div class="form-wrapper cf" > 
<form accept-charset="UTF-8" action="/index.php" method="get"><div style="margin:0;padding:0;display:inline"><input name="a" type="hidden" value="search"/></div> 
<input id="search" name="q" type="text"/> 
<button type="submit">Search</button> 
</form> 
</div>