Amir
Amir

Reputation: 4111

Block URL with htaccess

How to block an URL ended with 'select-a-plan.html' by htaccess? I tried

RewriteRule ^/select-a-plan.html$ - [F]

and

RewriteCond %{REQUEST_URI} ^/select-a-plan.html
RewriteRule ^(.*)$ - [F,L]

with no success

Upvotes: 2

Views: 433

Answers (1)

RavinderSingh13
RavinderSingh13

Reputation: 133428

With your shown samples, could you please try following. Please clear your browser cache before testing your URLs.

RewriteEngine ON
RewriteRule select-a-plan\.html/?$ - [NC,F]

Fixes in OP's nice attempts:

  1. First thing first when using match with RewriteRule it never starts from / to your regex ^/ will not match here.
  2. I have used NC FLAG of apache to enable ignorecase for matching any case file name.
  3. Also since string select-a-plan.html will be at last of the uri so we need not to use ^(caret) at first place because it assumes we are matching it from starting of uri.

Upvotes: 3

Related Questions