【问题标题】:Using htaccess how to check if request is Drupal's Front Page?使用 htaccess 如何检查请求是否是 Drupal Front Page?
【发布时间】:2015-08-27 09:02:18
【问题描述】:

我正在尝试配置 Drupal 7 主 .htaccess 文件,在检查 .htaccess 中的某些条件(RewriteCond)后,我需要再检查一个条件(RewriteCond);如果请求是针对 Drupal Front Page。
如果请求是针对首页的,则将其重定向到某个地方,例如“newfrontpage”一个现有页面。

我尝试了什么:

RewriteCond %{REQUEST_URI} ^/index\.php$ #line1
RewriteRule ^(.*)$ http://example.com/newfrontpage [L,NC] #line2

我尝试使用#line1 的其他选项是:

RewriteCond %{REQUEST_URI} ^$
RewriteCond %{REQUEST_URI} ^/node$

没有任何效果。
其他方法可能是 hook_process_page(&$variables) 并检查 if($variables['is_front']).. 但我认为 .htaccess 会更优化!

【问题讨论】:

    标签: php apache .htaccess drupal drupal-7


    【解决方案1】:

    您为什么不在 Drupal 的设置中设置首页?只需转到配置 -> 系统 -> 网站信息 (admin/config/system/site-information) 并将路径设置为您的默认首页。

    【讨论】:

    • 是的,你是对的,但我需要有条件的登陆页面。
    猜你喜欢
    • 2021-06-25
    • 1970-01-01
    • 2016-07-29
    • 2017-02-11
    • 1970-01-01
    • 2015-05-27
    • 2018-03-09
    • 2014-05-16
    相关资源
    最近更新 更多