【问题标题】:htaccess conflict between web route and public directoryweb路由和公共目录之间的htaccess冲突
【发布时间】:2016-02-13 00:06:12
【问题描述】:

我有一个带有第三方模块的 Magento 项目,该模块在 /sitemap 路由处创建 HTML 站点地图。同时,我们有一个站点地图目录,其中包含一堆可公开访问的 XML 站点地图(发布到 Google 等)。使用站点地图目录,/sitemap 路由会导致重定向循环。

我正在寻找一个 htaccess 重写规则,它允许我通过 Magento 中的标准 index.php 路由机制提供 /sitemap URL,但允许将 sitemap/*.xml 作为文件提供。

这是我的尝试,我希望检查 URI 是否包含 /sitemap 并且不是文件,然后将当前请求重写为 HTML 站点地图模块的完整 URL,但它似乎没有任何效果。

RewriteCond %{REQUEST_URI} ^sitemap
RewriteCond %{REQUEST_URI} !-f
RewriteRule %{REQUEST_URI} sitemap/index/index #The full URL of the HTML sitemap page.

【问题讨论】:

  • 重写规则 ^([a-z_]+)\.php$ /%1/$1.xml [L]

标签: php apache .htaccess magento mod-rewrite


【解决方案1】:

改变:

RewriteCond %{REQUEST_URI} !-f

 RewriteCond %{REQUEST_FILENAME} !-f

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-28
    • 2016-03-06
    • 1970-01-01
    • 2015-11-14
    • 1970-01-01
    • 1970-01-01
    • 2010-10-01
    • 1970-01-01
    相关资源
    最近更新 更多