Magento-自定义模块Url
我收到一个更改模块url的请求 例如,假设url是www.example.com/world 我需要的url是www.example.com/hello/world 我知道在modules config xml中,您可以将节点更改为您喜欢的任何形式(只要它是唯一的),但不允许prepend/hello/Magento-自定义模块Url,magento,url-rewriting,module,Magento,Url Rewriting,Module,我收到一个更改模块url的请求 例如,假设url是www.example.com/world 我需要的url是www.example.com/hello/world 我知道在modules config xml中,您可以将节点更改为您喜欢的任何形式(只要它是唯一的),但不允许prepend/hello/ <frontend> <routers> <anexample> <use>standard&l
<frontend>
<routers>
<anexample>
<use>standard</use>
<args>
<module>An_Example</module>
<frontName>hello/world</frontName>
</args>
</anexample>
</routers>
</frontend>
标准
一个例子
你好/世界
有人知道怎么做吗?一些示例代码,甚至是正确方向上的一点,都将不胜感激
如果这不够详细,我很抱歉,如果需要,我很乐意发布更多的代码
提前谢谢 请看以下艾伦·斯托姆关于Magento重写的文章
请参阅以下艾伦·斯托姆关于Magento重写的文章
在这里,我可以为您提供解决方案的想法,它肯定会对您有所帮助
<?xml version="1.0"?>
<config>
<global>
<rewrite>
<some_unique_name_to_identify_this_rewrite>
<from><![CDATA[#^/from_this/#]]></from>
<to>/to_this/</to>
</some_unique_name_to_identify_this_rewrite>
</rewrite>
</global>
</config>
通过这种方式,您正在使系统的目标重写您的起点
希望这肯定会对你有所帮助在这里,我可以给你一些想法,让你找到解决方案,这肯定会对你有所帮助
<?xml version="1.0"?>
<config>
<global>
<rewrite>
<some_unique_name_to_identify_this_rewrite>
<from><![CDATA[#^/from_this/#]]></from>
<to>/to_this/</to>
</some_unique_name_to_identify_this_rewrite>
</rewrite>
</global>
</config>
通过这种方式,您正在使系统的目标重写您的起点
希望这一定会帮助您您可以将重写添加到Magento的URL重写管理器中。尚未测试以下代码。但希望它能有所帮助
<?xml version="1.0"?>
<config>
<global>
<rewrite>
<some_unique_name_to_identify_this_rewrite>
<from><![CDATA[#^/from_this/#]]></from>
<to>/to_this/</to>
</some_unique_name_to_identify_this_rewrite>
</rewrite>
</global>
</config>
Mage::getModel('core/url_rewrite')
->setIsSystem(0)
->setStoreId($storeId)
->setOptions('RP')
->setIdPath('index.php?cat=c' . $categoryId . '_' . $this->strip($data['name']) . '.html')
->setTargetPath($categoryModel->getUrlPath() . '.html')// Put the actual path
->setRequestPath('index.php?cat=c' . $categoryId . '_' . $this->strip($data['name']) . '.html') // put the path you want to display
->save();
您可以将重写添加到Magento的URL重写管理器中。尚未测试以下代码。但希望它能有所帮助
Mage::getModel('core/url_rewrite')
->setIsSystem(0)
->setStoreId($storeId)
->setOptions('RP')
->setIdPath('index.php?cat=c' . $categoryId . '_' . $this->strip($data['name']) . '.html')
->setTargetPath($categoryModel->getUrlPath() . '.html')// Put the actual path
->setRequestPath('index.php?cat=c' . $categoryId . '_' . $this->strip($data['name']) . '.html') // put the path you want to display
->save();
这最终相当简单。我没有为它创建重写,而是将我的frontname更改为“hello”,然后创建了一个名为“worldController”的控制器
然后在我的indexController中,我将重定向到*/world这最终非常简单。我没有为它创建重写,而是将我的frontname更改为“hello”,然后创建了一个名为“worldController”的控制器
然后,在我的indexController中,我将重定向到*/world作为自定义HTML Url链接访问自定义模块控制器路径 说 将重写为 在core_url_重写表中插入以下数据以进行url重写
Mage::getModel('core/url_rewrite')
->setStoreId(1)
->setIdPath('customwallpaper')
->setRequestPath('fotomural-personalizado.html')
->setTargetPath('customwallpaper/index/create') // Put the actual Controller path
->setIsSystem(1)
->save();
-或-
在sql查询下面运行
INSERT INTO `core_url_rewrite`
(`url_rewrite_id`, `store_id`, `id_path`, `request_path`, `target_path`, `is_system`, `options`, `description`, `category_id`, `product_id`)
VALUES ('7', '1', 'customwallpaper', 'fotomural-personalizado.html', 'customwallpaper/index/create', '1', NULL, NULL, NULL, NULL);
以自定义HTML Url链接的形式访问自定义模块控制器路径 说 将重写为 在core_url_重写表中插入以下数据以进行url重写
Mage::getModel('core/url_rewrite')
->setStoreId(1)
->setIdPath('customwallpaper')
->setRequestPath('fotomural-personalizado.html')
->setTargetPath('customwallpaper/index/create') // Put the actual Controller path
->setIsSystem(1)
->save();
-或-
在sql查询下面运行
INSERT INTO `core_url_rewrite`
(`url_rewrite_id`, `store_id`, `id_path`, `request_path`, `target_path`, `is_system`, `options`, `description`, `category_id`, `product_id`)
VALUES ('7', '1', 'customwallpaper', 'fotomural-personalizado.html', 'customwallpaper/index/create', '1', NULL, NULL, NULL, NULL);
不幸的是,这对我帮助不大。我已经尝试过在xml中使用和,但没有什么影响。通常导致404或根本不重定向。我肯定我只是错过了一些明显的东西,但我盯着它看了这么久,一切都变成了胡言乱语。不幸的是,这对我帮助不大。我已经尝试过在xml中使用和,但没有什么影响。通常导致404或根本不重定向。我肯定我只是错过了一些明显的东西,但我盯着它看了这么久,一切都变成了胡言乱语。