.htaccess 如何在OpenCart 2.x中停止/重定向非seo友好url到其url别名?
如何在OpenCart 2.x中将不支持seo的url永久重定向到url别名(301)?例如,对我来说,url和.htaccess 如何在OpenCart 2.x中停止/重定向非seo友好url到其url别名?,.htaccess,redirect,opencart2.x,.htaccess,Redirect,Opencart2.x,如何在OpenCart 2.x中将不支持seo的url永久重定向到url别名(301)?例如,对我来说,url和 当有人点击url示例{dot}com/index.php?route=account/login时,我想重定向301到他们各自的url别名url示例{dot}com/login。我认为下面的vqmod\u seo\u url.xml将解决您的问题 <modification> <id>seo_url_core</id> <ve
当有人点击url示例{dot}com/index.php?route=account/login时,我想重定向301到他们各自的url别名url示例{dot}com/login。我认为下面的
vqmod\u seo\u url.xml
将解决您的问题
<modification>
<id>seo_url_core</id>
<version>1.4.x and above</version>
<vqmver required="true">2.x.x</vqmver>
<file name="catalog/controller/common/seo_url.php">
<operation error="skip">
<search position="before" offset="0">
<![CDATA[
public function index() {
]]>
</search>
<add>
<![CDATA[
/* SEO Custom URL */
private $url_list = array (
'common/home' => '',
'checkout/cart' => 'cart',
'account/register' => 'register',
'account/wishlist' => 'wishlist',
'checkout/checkout' => 'checkout',
'account/login' => 'login',
'product/special' => 'special',
'affiliate/account' => 'affiliate',
'checkout/voucher' => 'voucher',
'product/manufacturer' => 'brand',
'account/newsletter' => 'newsletter',
'account/order' => 'order',
'account/account' => 'account',
'information/contact' => 'contact',
'account/return/insert' => 'return',
'information/sitemap' => 'sitemap',
);
/* SEO Custom URL */
]]>
</add>
</operation>
<operation error="skip">
<search position="before">
<![CDATA[
if (!isset($this->request->get['route'])) {
]]>
</search>
<add>
<![CDATA[
/* SEO Custom URL */
if ( $_s = $this->setURL($this->request->get['_route_']) ) {
$this->request->get['route'] = $_s;
}/* SEO Custom URL */
]]>
</add>
</operation>
<operation error="skip">
<search position="before" offset="3">
<![CDATA[
if ($url) {
]]>
</search>
<add>
<![CDATA[
/* SEO Custom URL */
if( $_u = $this->getURL($data['route']) ){
$url .= $_u;
unset($data[$key]);
}
/* SEO Custom URL */
]]>
</add>
</operation>
<operation error="skip">
<search position="after" index="1" offset="2">
<![CDATA[
return $link;
]]>
</search>
<add>
<![CDATA[
/* SEO Custom URL */
public function getURL($route) {
if( count($this->url_list) > 0) {
foreach ($this->url_list as $key => $value) {
if($route == $key) {
return '/'.$value;
}
}
}
return false;
}
public function setURL($_route) {
if( count($this->url_list) > 0 ){
foreach ($this->url_list as $key => $value) {
if($_route == $value) {
return $key;
}
}
}
return false;
}/* SEO Custom URL */
]]>
</add>
</operation>
</file>
</modification>
搜索引擎优化url核心
1.4.x及以上
2.x.x
'',
“结帐/购物车”=>“购物车”,
'帐户/寄存器'=>'寄存器',
“帐户/愿望列表”=>“愿望列表”,
“签出/签出”=>“签出”,
'帐户/登录'=>'登录',
“产品/特殊”=>“特殊”,
“附属公司/账户”=>“附属公司”,
“结帐/凭证”=>“凭证”,
“产品/制造商”=>“品牌”,
“账户/通讯”=>“通讯”,
“账户/订单”=>“订单”,
'科目/科目'=>'科目',
'信息/联系人'=>'联系人',
'帐户/返回/插入'=>'返回',
“信息/站点地图”=>“站点地图”,
);
/*SEO自定义URL*/
]]>
请求->获取['route'])){
]]>
setURL($this->request->get[''u route\'])){
$this->request->get['route']=$\u;
}/*SEO自定义URL*/
]]>
getURL($data['route'])){
$url.=$\u;
未设置($data[$key]);
}
/*SEO自定义URL*/
]]>
url(列表)>0){
foreach($key=>$value形式的此->url\u列表){
如果($route==$key){
返回“/”.$value;
}
}
}
返回false;
}
公共函数setURL($\u路由){
如果(计数($this->url\u列表)>0){
foreach($key=>$value形式的此->url\u列表){
如果($\路由==$值){
返回$key;
}
}
}
返回false;
}/*SEO自定义URL*/
]]>
php方式-只需反转seo_url.php代码即可。在oc中,它负责查找特定sef关键字的路由。现在您有了路由,找到sef关键字并重定向到该路径。您可以共享代码吗?我对OpenCart有点陌生。我也有同样的问题,这对我在2.1上的表现很有帮助,谢谢@zed blackbeard分享vqmod的seo url。我找到了解决办法。