从index.php重写?type = search& q = * to search /?q = *

时间:2015-01-15 13:15:39

标签: .htaccess url-rewriting

我想重写的网址是:

  

http://domain.com/index.php?type=search&q=something

  

http://domain.com/search/?q=something

我创建了.htaccess文件并将此代码重写为:

RewriteEngine On  
RewriteRule ^search/?q=(.*)$ index.php?type=search&q=$1 [QSA,L]

但它没有用。

1 个答案:

答案 0 :(得分:1)

您可以使用:

RewriteEngine On 
RewriteCond %{QUERY_STRING} ^q=(.*)$
RewriteRule ^search/$ index.php?type=search&q=%1 [L]