CLEAN URL - 将特定于 Drupal 的设置直接包含到 .htaccess 中

CLEAN URL - Include the Drupal-specific settings directly into .htaccess

我读了Configure clean URL

它要求将下面的代码添加到 .htaccess 文件中。

<Directory /var/www/example.com>
  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?q= [L,QSA]
</Directory>

/var/www/drupal是我复制所有Drupal文件的目录。

所以我应该添加的最终代码是

<Directory /var/www/drupal>
  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?q= [L,QSA]
</Directory>

对吗?

它说在配置文件中使用它。您不能在 .htaccess 中使用 <Directory> 指令。 .htaccess 的本质已经是每个目录上下文。删除指令并仅使用重写规则。这仅适用于 Drupal 6

  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?q= [L,QSA]

Drupal 7 或 8

  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^ index.php [L]

尝试了解说明的内容,您需要使用合适的说明进行安装。您提供的 link 是非常详细的信息。