重写条件不起作用 [英] Rewrite condition is not working

查看:86
本文介绍了重写条件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何像在opencart中那样重写我的搜索页面的URL

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

但是我需要将其显示为

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]

推荐答案

这是怎么回事:

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

请注意,route参数中的斜线使事情复杂化.

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

这篇关于重写条件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆