【问题标题】:htaccess want to cut folder in urlhtaccess 想在 url 中剪切文件夹
【发布时间】:2014-03-27 14:16:47
【问题描述】:

我正在寻找一个 htaccess 规则,现在当我在搜索后单击产品时,它会在 url 中剪切文件夹名称,我得到一个 404 路径 ist

DOMAIN.COM/magento/index.php/catalog/product/view/s/sony-ericsson-w810i/

我想要的是我点击并获得这条路径:

域:COM/magento/index.php/sony-ericsson-w810i.html

所以它只是切割目录/产品/视图/s/部分......这部分是静态的,但后面的名称(在这种情况下是手机)是动态的......

谁能给我正确的 htacces 重写规则?

谢谢你:)

【问题讨论】:

    标签: php apache .htaccess magento mod-rewrite


    【解决方案1】:

    以下规则应该实现您正在寻找的东西

    RewriteRule ^magento/index.php/catalog/product/view/s/(.*)$ /magento/index.php/$1.html [R=302,L]
    

    当您确定重定向有效时,将 R=302 更改为 R=301

    【讨论】:

    • 添加后会发生什么(RewriteEngine On 行之后)?
    • 在重写后添加了它,但没有更改 url 中的任何内容,但我认为现在它似乎是 php/database 中的一个问题,所以我要修复这个看起来更干净但感谢帮助:)
    • 你能发布 htacces 文件的内容吗?
    • 整个文件有 210 行,它是一个普通的 magento htaccess 我刚刚在 RewriteRule 上添加了 Options +FollowSymLinks RewriteEngine ^magento.clean/index.php/catalog/product/view/s/(.*)$ /magento.clean/index.php/$1.html [R=302,L] 我添加的代码只是重写规则,其余用于放置:)
    • 文件夹名称是不是叫magento.clean
    猜你喜欢
    • 2013-07-18
    • 1970-01-01
    • 2020-01-13
    • 2016-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-08
    • 2013-01-24
    相关资源
    最近更新 更多