2013-11-21 30 views
0

參數爲:「route = product/search」和「path = 0」。我已經嘗試了很多東西,但是我對.htaccess的知識有限。.htaccess將具有某些參數的網址重定向到主頁

我想重定向以下網址: www.example.com/index.php?route=product/search &路徑= 0

到 www.example.com

無論我嘗試,它似乎沒有工作。什麼是最好的解決方案?

# SEO URL Settings 
RewriteEngine On 
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie./becomes /shop/ 

RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L] 
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L] 
RewriteRule ^download/(.*) /index.php?route=error/not_found [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css) 
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA] 

### below send all calls to www 
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC] 
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 


RewriteCond %{QUERY_STRING} (^|&)route=product/search(&|$) [NC] 
RewriteCond %{QUERY_STRING} (^|&)path=0(&|$) [NC] 
RewriteRule ^index.php$/[R=301,NC] 

回答

0

這些指令添加到您的主.htaccess

RewriteEngine on 

RewriteCond %{QUERY_STRING} (^|&)route=product/search(&|$) [NC] 
RewriteCond %{QUERY_STRING} (^|&)path=0(&|$) [NC] 
RewriteRule ^index.php$ /? [R=301,NC] 

你也是的RewriteCond在第四重寫規則缺失(其防止網址與index.php文件開始從重寫),你的.htaccess將是:

# SEO URL Settings 
RewriteEngine On 
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie./becomes /shop/ 

RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L] 
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L] 
RewriteRule ^download/(.*) /index.php?route=error/not_found [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css) 
RewriteCond %{REQUEST_URI} !^index.php 
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA] 

### below send all calls to www 
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC] 
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 


RewriteCond %{QUERY_STRING} (^|&)route=product/search(&|$) [NC] 
RewriteCond %{QUERY_STRING} (^|&)path=0(&|$) [NC] 
RewriteRule ^index.php$ /? [R=301,NC] 
+0

親愛的胺,謝謝你的答案。可悲的是,它不工作。我用我的htaccess文件更新了這個問題。 –

+0

我已經忘了追加一個反斜槓,這將防止查詢字符串被附加了rwriterule,我已經更新了你的.htaccess,試試看(記得在測試前先清除瀏覽器緩存) –

+0

它的工作現在。非常感謝! –

相關問題