添加“$link=str_replace('index.php?route=”,“$link);”时出现错误404在OpenCart中的seo_url.php中
我正在删除OpenCart URL上的index.php?route=common/home。我正在使用它的最新版本。我试过:添加“$link=str_replace('index.php?route=”,“$link);”时出现错误404在OpenCart中的seo_url.php中,php,url,content-management-system,localhost,opencart,Php,Url,Content Management System,Localhost,Opencart,我正在删除OpenCart URL上的index.php?route=common/home。我正在使用它的最新版本。我试过: $link = str_replace('index.php?route=', '', $link); 但它把我引向了页面: 找不到对象……错误404 您面临的问题是.htaccess文件和其中定义的重写规则。因为规则是在SEO URL打开时重写URL,如 像URL一样 这是为了搜索引擎优化网址。如果您试图创建自己的SEO URL,您还需要修改重写规则,例如从 Re
$link = str_replace('index.php?route=', '', $link);
但它把我引向了页面:
找不到对象……错误404
您面临的问题是.htaccess文件和其中定义的重写规则。因为规则是在SEO URL打开时重写URL,如 像URL一样 这是为了搜索引擎优化网址。如果您试图创建自己的SEO URL,您还需要修改重写规则,例如从
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
进入
没有测试这个我想你想要的是每个默认opencart功能的sef url,对吗?如果是这样,你可以使用一个插件,来自anung,在官方的opencart板上。这个想法是在检查请求路径之前,在catalog/controller/common/seo_url.php上创建一个包含所有默认路由的大型if/elseif,如下所示:
} elseif ($this->request->get['_route_'] == 'contato') {
$this->request->get['route'] = 'information/contact';
} elseif ($this->request->get['_route_'] == 'account') {
$this->request->get['route'] = 'account/account';
} elseif (isset($this->request->get['path'])) {
然后,在检查$key==“path”之前,检查您的路由:
} elseif (isset($data['route']) && $data['route'] == 'information/contact') {
$url .= '/contato';
} elseif (isset($data['route']) && $data['route'] == 'account/account') {
$url .= '/account';
} elseif ($key == 'path') {
如果你想要这个插件,你可以在官方opencart板上搜索它。替换str_之前的$link是什么。它后面是什么?你希望它是什么?否则{$link=str_replace'index.php?route=',$link;return$link;}@wizkid$link前后的值是什么?你希望它是什么?例如,当我插入上述代码时,签出opencart中的默认URL变成了www.abc.com/Checkout/Checkout。但是,它没有显示签出的内容,而是显示您请求的页面“找不到!”@那不是我的问题。之前和之后的价值是什么?您希望它是什么?
} elseif (isset($data['route']) && $data['route'] == 'information/contact') {
$url .= '/contato';
} elseif (isset($data['route']) && $data['route'] == 'account/account') {
$url .= '/account';
} elseif ($key == 'path') {