改写谷歌定制搜索字符串字符串

2023-09-02 20:32:54 作者:老巷枯井

我的previous定制的谷歌搜索出现这个怎么样:

My previous custom google search appeared this how:

(第一个链接) http:/raskim.lt/controller/function/music?cx=014092587915392242087%3Agc6l6xlpkmq&cof=FORID%3A11&q=this%is%example&sa=Search

(first link) http:/raskim.lt/controller/function/music?cx=014092587915392242087%3Agc6l6xlpkmq&cof=FORID%3A11&q=this%is%example&sa=Search

我改变我的谷歌自定义搜索引擎的脚本。现在,IM usign JSAPI。我的新的搜索产生:

I change my Google CSE script. Now im usign jsapi. My new search generates:

(第二个链接)HTTP:/raskim.lt/controller/function/music Q =此%是%例子

(second link) http:/raskim.lt/controller/function/music?q=this%is%example

如何重写URL,如果有人访问一个链接,会被重定向到第二个链接?

How to rewrite url that if someone visit first link, would be redirected to second link?

现在我的.htaccess如下:

Now my .htaccess looks:

<IfModule mod_rewrite.c>

Options +FollowSymLinks -Indexes
RewriteEngine on


#AllowOverride All
#RewriteBase /
    RewriteCond %{HTTP_HOST} !^www.raskim.lt$
    RewriteRule ^(.*)$ http://www.raskim.lt/$1 [L,R=301]
# Restrict your site to only one domain
#RewriteCond %{HTTP_HOST} !^www.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_php5.c>
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

推荐答案

添加到您的的.htaccess 在Web根 / 目录

Add this to your .htaccess in your web root / directory

RewriteEngine on
RewriteBase /

RewriteCond %{QUERY_STRING} &q=([^&]+) [NC]
RewriteRule ^(.*/music)$ $1?q=%1 [R=301,NC,L]