1

Magentoでは、モジュールのURL構造は次のようになります。

example.com/[index.php]/:module/:controller/:action/:param1[/:paramN ...]

ギャラリーモジュールを作成しました。ギャラリーにはいくつかのアルバムが含まれており、各アルバムのURLは次のようになります(MagentoのURL構造に従います)。

example.com/[index.php]/gallery/controller/view/name/:album_name

しかし、ギャラリーの各アルバムのURLは次のようになります。

example.com/[index.php]/gallery/:album_name

どうすればこれを達成できますか?.htaccess Rewrite Ruleを試しましたが、間違っているようで、機能していません。これがMagentoの.htaccess書き換えルールのコピーです

<IfModule mod_rewrite.c>
    ## enable rewrites
    Options +FollowSymLinks
    RewriteEngine on

    ## workaround for HTTP authorization
    ## in CGI environment
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    ## Rewrite Rule for Gallery Module
    RewriteRule ^/gallery/(.*)?$ /gallery/category/view/name/$1 [L]


    ## always send 404 on missing files in these folders
    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

    ## never rewrite for existing files, directories and links
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

    ## rewrite everything else to index.php
    RewriteRule .* index.php [L]    

</IfModule>
4

2 に答える 2

4

これは、confix.xmlでmagento url rewriteを使用して実現できます(apache rewriteを使用する必要はありません)。

<global>
     <rewrite>
       <fancy_url>
             <from><![CDATA[/customModule\/(.*)/]]></from>
             <to><![CDATA[customModule/controller/view/name/$1/]]></to>
             <complete>1</complete>
        </fancy_url>
     <rewrite>
</global>

続きを読む@ config.xmlを使用してmagentoで簡単なURL書き換えを行う

私の答えを参照してください@MagentoルーターのURL-:album_nameにアクセスする方法については、ハイフン付きのパス名が必要です

于 2012-11-20T16:01:55.400 に答える
1

多くのルートで汎用的にルーティングをカスタマイズする必要がある場合は、カスタムルータークラスを簡単に実装できます(参照Mage_Cms_Controller_Router[リンク]オブザーバーとしての構成[リンク])。

于 2012-11-20T14:38:09.030 に答える