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

50 views Asked by At

I read the Configure clean URL

It ask to add the code below into .htaccess file.

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

/var/www/drupal is the directory where I copied all the Drupal files.

So the final code should I add into it is

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

Is that right?

1

There are 1 answers

3
Panama Jack On BEST ANSWER

It says to use that in the configuration file. You can not use <Directory> directive inside .htaccess. The very nature of .htaccess is already per directory context. Remove the directive and only use the rewriterules. This is only for Drupal 6

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

Drupal 7 or 8

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

Try to understand what the instructions have and you need to use the appropriate one for your install. The link you provide is pretty detailed info.