【问题标题】:Rewrite url writing using htaccess to access in a folder from root使用 htaccess 重写 url 写入以从根目录访问文件夹
【发布时间】:2014-12-18 09:24:24
【问题描述】:

我想从根目录向我的一个子文件夹写入一个重写 url。 例如:www.mydomain.com/subscriber.html

想要重定向到

www.mydomain.com/subscriber/index.php

我在我的 magento 根 .htaccess 文件中使用了以下代码。

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)\.htm$ subscriber/$1.php [R,NC]

但它不起作用。任何人都可以帮我解决这个问题吗?

【问题讨论】:

    标签: php apache .htaccess magento mod-rewrite


    【解决方案1】:

    您可以从管理面板重写 url,如下所示: 目录 => URL 重写管理

    【讨论】:

    • 谢谢。这是为订阅者定制的文件夹。管理面板中自定义重写页面中的 id 路径是什么。
    • id 路径将是您的页面 id ex.subscriber.html,请求路径将是subscriber/index.php。
    【解决方案2】:

    试试这个:

    RewriteRule ^(.*)\.html$ $1/index.php [QSA,L]

    【讨论】:

    • 重定向引擎如何验证这是要转到特定文件夹?如果我们这样写?
    • 这是你想要的吗? www.aaa.com/xxx.html -> www.aaa.com/xxx/index.php
    【解决方案3】:

    试试这个

    Redirect 301 /subscriber.html /subscriber/index.php
    

    【讨论】:

      【解决方案4】:

      以下示例可能会有所帮助

      RewriteRule ^(.+)\.html$ $1/index.php [R,NC]
      

      如果您有要重定向到的特定页面 foo.html 和文件夹 foo,那么以下示例可能会有所帮助

      RewriteRule ^foo\.html$ foo/index.php
      

      【讨论】:

        猜你喜欢
        • 2021-07-01
        • 2015-11-11
        • 2021-02-11
        • 1970-01-01
        • 2020-01-08
        • 2013-10-23
        • 2011-09-13
        • 2016-01-05
        相关资源
        最近更新 更多