php - opencart 中的 URL 重写

标签 php url url-rewriting opencart

如何在 opencart 中重写我的搜索页面的 URL。
当前网址是:

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

但我需要像这样显示它:
http://localhost/opencart/product/search/42

或任何用户友好的 URL 格式。
我试过这个:
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]

最佳答案

这个怎么样

RewriteEngine On
RewriteBase /opencart
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^product/search/([0-9]*)$ index.php?route=product/search&filter_name=$1 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteCond %{REQUEST_URI} !^/search$
RewriteRule ^([^?]*) index.php?route=$1 [L,QSA]

RewriteBase 中测试对我来说很好用提供您的文件夹名称

关于php - opencart 中的 URL 重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65974879/

相关文章:

php - 删除单个 PHP 扩展

javascript - 谷歌地图半径

php - SoapFault 异常 : [HTTP] Error Fetching http headers

macos - 当 OS X 应用程序通过注册的 URL 方案启动时,如何访问完整的 URL?

php - URL 重写(内部/外部转发器).htaccess

nginx - 将nginx主机和proxypass重写为squid

php - 选择左连接,除了一列

php - 基于多个 GET 变量的动态查询(Refine Search Form)

php - Laravel 8 路由到 Controller 。 SEO 友好的 URL 结构

java - Jsp自动转发