在 Magento 上,模块的 URL 结构如下所示:
example.com/[index.php]/:module/:controller/:action/:param1[/:paramN ...]
我创建了一个画廊模块。图库包含多个专辑,每个专辑的 URL 如下所示(遵循 Magento URL 结构):
example.com/[index.php]/gallery/controller/view/name/:album_name
但我希望画廊上每张专辑的网址是这样的:
example.com/[index.php]/gallery/:album_name
我怎样才能做到这一点?我已经尝试过 .htaccess 重写规则,但似乎我弄错了,它不起作用。这是我的 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>