Adam
Adam

Reputation: 85

Apache .htaccess mod_rewrite multiple RewriteRules

I have migrated my site to a wordpress site and set up the permalinks to be the post name. I need to add a rewriteRule to take anything from a cgi directory and just send them to the home page Ive tried:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
RewriteRule ^cgi(.*)$ http://example.com

Removing the [L] from the wordpress rule and adding the last line but it still doesnt work. Can someone tell me what I'm doing wrong?

Upvotes: 1

Views: 29

Answers (1)

anubhava
anubhava

Reputation: 786091

Keep L flag as before and your cgi rule should be placed below RewriteBase line:

RewriteEngine On
RewriteBase /

RewriteRule ^cgi(.*)$ / [L,NC,R]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Upvotes: 1

Related Questions