【问题标题】:Rewrite Rule custom index file Drupal installationRewrite Rule 自定义索引文件 Drupal 安装
【发布时间】:2013-01-26 19:28:01
【问题描述】:

这是在我的 htaccess 文件中设置的 Drupal 当前的 Rewrite 规则:

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteCond %{REQUEST_URI} !=/index.html
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

这很好用,但问题是我想要一个自定义页面,当人们浏览网站时会打开它。更具体:

www.company.com/ 应该打开 index.html 所有其他页面都应该使用 Drupal 的默认重写规则。

我尝试编辑 DirectoryIndex,但所有页面都被重定向到 index.html。

DirectoryIndex index.html index.php

我也尝试添加不同的重写规则,但我还没有任何运气。 Htaccess 不是我最好的技能。

  RewriteCond %{REQUEST_URI} ^/$ [NC]
  RewriteRule ^/$ /index.html [L]

可能会有一个简单的解决方案,但我不知道该怎么做。

有人知道如何解决我的问题吗?

谢谢!

【问题讨论】:

    标签: .htaccess drupal mod-rewrite rewrite directoryindex


    【解决方案1】:

    尝试将 301 代码添加到规则中,这意味着永久移动。

    RewriteCond %{REQUEST_URI} ^/$ [NC]
    RewriteRule ^/$ /index.html [L,R=301]
    

    【讨论】:

    • 感谢您的回复。我尝试添加 301 规则,但没有解决问题。这就是我现在所拥有的:RewriteCond %{HTTP_HOST} ^(www.)?domain.com(/)?$ RewriteCond %{REQUEST_URI} ^/?$ RewriteRule ^/?$ index.html [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteCond %{REQUEST_URI} !=/index.html RewriteCond %{REQUEST_URI} !^/?$ RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] 这很好用,但是当我转到 domain.com/?q= 时,它会显示我的 index.html 文件而不是 Drupal 节点。
    猜你喜欢
    • 2019-03-15
    • 2015-10-12
    • 2023-04-01
    • 2014-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-22
    • 1970-01-01
    相关资源
    最近更新 更多