开发者

NC flag in htaccess causing Internal Server Error

开发者 https://www.devze.com 2023-04-07 17:46 出处:网络
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

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?


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号