Rewrite condition is not working

2019-04-16 00:57发布

How to rewrite the URL for my search page in opencart that is like

http://IP/opencart/index.php?route=product/search&filter_name=24

But I need to display it like

http://localhost/opencart/product/search/42

orelse in any formate that is an userfreindly.I have tried like

RewriteEngine On
RewriteBase /opencart
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [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]

RewriteBase /opencart 
RewriteRule ^search$ index.php?route=product/search  [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/search$
RewriteRule ^([^?]*) index.php?route=$1 [L,QSA]

1条回答
在下西门庆
2楼-- · 2019-04-16 01:02

How about this:

RewriteBase /
RewriteRule ^opencart/([^/]*)/([^/]*)/([^/]*)$ /opencart/index.php?route=$1/$2&filter_name=$3 [L]

Please note that the slash in the route parameter complicates things.

查看更多
登录 后发表回答