1

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?

user73963
  • 165
  • 1
  • 1
  • 5

1 Answers1

2

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.

Panama Jack
  • 24,158
  • 10
  • 63
  • 95
  • I have tried remove directive inside .htaccess. But it still can't enabled the CLEAN URL. Do I need to restart apache after make the changes? – user73963 Jun 25 '15 at 23:45
  • If you had inside .htaccess file and you did **not** get a **500 internal error** then your .htaccess file not being read and is not enabled. You need to add `AllowOverride All` in your Apache config/virtual host file and restart Apache. – Panama Jack Jun 26 '15 at 03:39
  • Thanks for your answer. I just found AllowOverride None is in another file. Can you help me take a look for this question http://stackoverflow.com/questions/31064092/change-allowoverride-none-to-allowoverride-all – user73963 Jun 26 '15 at 03:49