1

I am using this code that blocks a URL with the word foo

RewriteEngine On RewriteRule ^foo - [F] 

It works fine, but, how do I make it work with the existing .htaccess code from WP which is below?

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

1 Answer 1

1

It's just a case of putting that rule before the WordPress code block.

For example:

# Block all URLs that start with "/foo" RewriteRule ^foo - [F] # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress 

See also my answer to the following question on the WordPress SE site that goes into detail if you are still having problems:

Sign up to request clarification or add additional context in comments.

1 Comment

It is before the WP block, but what was lacking was ErrorDocument 403 default.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.