Search code examples
.htaccesscase-insensitive

NC flag in htaccess causing Internal Server Error


Whenever I add the [NC] flag in .htaccess, it causes an Internal Server Error.

This works:

Redirect 301 /gabf http://www.mydomain.com/category/gabf

but this doesn't:

Redirect 301 /gabf http://www.mydomain.com/category/gabf [NC]

How can I allow things like /gabf, /GABF, /Gabf, etc?


Solution

  • Use this code:

    RewriteEngine ON
    RewriteRule ^gabf/?$ http://www.domain.com/category/gabf [R=301,NC,L]
    

    before:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteRule ^index\.php$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]
    </IfModule>
    

    Wordpress overwrite all RewriteRule to index.php. If you put that first, this "gabf" rule will be executed first and since it's the last rule it will stop.

    R=301 = Redirect Permanent and NC = No Case (case insensitive)