.htaccess 产品过滤器的Opencart SEO URL

.htaccess 产品过滤器的Opencart SEO URL,.htaccess,filter,seo,opencart,.htaccess,Filter,Seo,Opencart,我最近有机会在Opencart上工作,我得到了一个定制的主题(Pav foodstore)。 我试图在我的项目中实现自动搜索引擎优化URL。为此,我从NavneetSingh下载了一个非常好的扩展,用于自动搜索引擎优化URL。问题是,它没有为产品过滤器提供SEO URL。尝试了一些修改,但似乎无法正常工作 以下是VQmod xml文件代码: <?xml version="1.0" encoding="UTF-8"?> <modification> <

我最近有机会在Opencart上工作,我得到了一个定制的主题(Pav foodstore)。 我试图在我的项目中实现自动搜索引擎优化URL。为此,我从NavneetSingh下载了一个非常好的扩展,用于自动搜索引擎优化URL。问题是,它没有为产品过滤器提供SEO URL。尝试了一些修改,但似乎无法正常工作

以下是VQmod xml文件代码:

    <?xml version="1.0" encoding="UTF-8"?>
<modification>
    <id>CUSTOM CHANGES DONE BY NAVNEET SINGH</id>
    <version>1</version>
    <vqmver>1.0.0</vqmver>
    <author>NAVNEET SINGH</author>
    <!-- SEO URLS -->
    <file error="abort" name="system/library/response.php">
        <operation>
            <search position="after"><![CDATA[ 
                public function output() {
            ]]></search>
            <add><![CDATA[  
            if ($this->output) {
                // REPLACE URLS WITH SEO URLS
                function my_repl($value) {
                    if( defined(ENT_COMPAT) && defined(ENT_HTML401) &&     defined(ENT_IGNORE) ) {
                        $val=str_replace(" ","-",strtolower(trim(strtr(html_entity_decode(strip_tags($value),ENT_COMPAT|ENT_HTML401|ENT_IGNORE,"UTF-8"),"`~!@#$%^&*()-_=+\\|[{]};:'\",<.>/?","                                "))));
                    return rawurlencode($val); }
                elseif( defined(ENT_COMPAT) && defined(ENT_IGNORE) ) {
                $val=str_replace(" ","-",strtolower(trim(strtr(html_entity_decode(strip_tags($value),ENT_COMPAT|ENT_IGNORE,"UTF-8"),"`~!@#$%^&*()-_=+\\|[{]};:'\",<.>/?","                                "))));
                    return rawurlencode($val); }
                else {
                $val=str_replace(" ","-",strtolower(trim(strtr(html_entity_decode(strip_tags($value),ENT_COMPAT,"UTF-8"),"`~!@#$%^&*()-_=+\\|[{]};:'\",<.>/?","                                "))));
                    return rawurlencode($val); }
            }
            function my_preg_replace($m1) {
                if($m1[1]=='information/information') $p2 = 'i';
                elseif($m1[1]=='product/category') $p2 = 'c';
                elseif($m1[1]=='product/category' && $m1[2]=='filter') $p2 = 'f';
                elseif($m1[1]=='product/manufacturer/info') $p2 = 'm';
                elseif($m1[1]=='product/product' && $m1[2]=='product_id') $p2 = 'pp';
                elseif($m1[1]=='product/product' && $m1[2]=='manufacturer_id') $p2 = 'pm';
                elseif($m1[1]=='product/product' && $m1[2]=='path') $p2 = 'pc';
                else return;

                // IF IMG TAG, USE IMG ALT TEXT IN SEO URL; ELSE, USE ANCHOR TEXT IN SEO URL
                if($p2=='i' || $p2=='c' || $p2=='m' || $p2=='pp') {
                    if( preg_match( '#<img.*alt="([^"]*)"#iUs', $m1[4], $m2 ) )
                        $u1 = my_repl($m2[1]);
                    else
                        $u1 = my_repl($m1[4]);
                    return $p2 . trim($m1[3]) . "-" . $u1 . '">' . $m1[4] . "</a>";
                }
                elseif($p2=='pc') {
                    if( preg_match( '#<img.*alt="([^"]*)"#iUs', $m1[5], $m2 ) )
                        $u1 = my_repl($m2[1]);
                    else
                        $u1 = my_repl($m1[5]);
                    return $p2 . trim($m1[4]) . "-c" . trim($m1[3]) . "-" . $u1 . '">' . $m1[5] . "</a>";
                }
                elseif($p2=='pm') {
                    if( preg_match( '#<img.*alt="([^"]*)"#iUs', $m1[5], $m2 ) )
                        $u1 = my_repl($m2[1]);
                    else
                        $u1 = my_repl($m1[5]);
                    return $p2 . trim($m1[4]) . "-m" . trim($m1[3]) . "-" . $u1 . '">' . $m1[5] . "</a>";
                }
            }
            // PATTERNS TO SEARCH FOR SEO URL REPLACEMENT
            $p1s = array(
            "#index\.php\?route\=(product/category)&amp;(path)=([0-9_]+?)\">(.*)</a>#iUs",
            "#index\.php\?route\=(product/category)&amp;(path)=([0-9_]+?)&amp;filter=([0-9]+?)\">(.*)</a>#iUs",
            "#index\.php\?route\=(product/manufacturer/info)&amp;(manufacturer_id)=([0-9]+?)\">(.*)</a>#iUs",
            "#index\.php\?route\=(information/information)&amp;(information_id)=([0-9]+?)\">(.*)</a>#iUs",
            "#index\.php\?route\=(product/product)&amp;(product_id)=([0-9]+?)[^\"]*\">(.*)</a>#iUs",
            "#index\.php\?route\=(product/product)&amp;(path)=([0-9_]+?)&amp;product_id=([0-9]+?)\">(.*)</a>#iUs",
            "#index\.php\?route\=(product/product)&amp;(manufacturer_id)=([0-9]+?)&amp;product_id=([0-9]+?)\">(.*)</a>#iUs",
            );
            $this->output = preg_replace_callback( $p1s, "my_preg_replace", $this->output );
        }
        ]]></add>
    </operation>
</file>
任何帮助都将不胜感激

RewriteEngine On
RewriteRule ^i([0-9]+)-(.*)$ index.php?route=information/information&information_id=$1 [L]
RewriteRule ^c([0-9_]+)-(.*)$ index.php?route=product/category&path=$1 [L]
RewriteRule ^c([0-9_]+)-f([0-9_]+)-(.*)$ index.php?route=product/category&path=$2&filter=$1 [L]
RewriteRule ^m([0-9]+)-(.*)$ index.php?route=product/manufacturer/info&manufacturer_id=$1 [L]
RewriteRule ^pp([0-9]+)-(.*)$ index.php?route=product/product&product_id=$1 [L]
RewriteRule ^pm([0-9]+)-m([0-9]+)-(.*)$ index.php?route=product/product&manufacturer_id=$2&product_id=$1 [L]
RewriteRule ^pc([0-9]+)-c([0-9_]+)-(.*)$ index.php?route=product/product&path=$2&product_id=$1 [L]