3

I'm working on a Drupal site, and the client has requested to prevent any direct access other than the URL aliases defined. That is,

  • www.clientsite.com -> Allowed
  • www.clientsite.com/some-internal-page -> Allowed
  • someclientsite.com/node/add -> Allowed
  • www.clientsite.com/node -> Denied
  • www.clientsite.com/node/72 -> Denied

As you can see, I need to disable /node, /node/ and /node/[0-9]* while allowing any /node/some-link-text

I've tried

<LocationMatch ^/node[\/]?([\d]*) > SetHandler server-status Order deny,allow Deny from all </LocationMatch> 

but it doesn't work for /node/add, though all other links work. What regex do I need to fit these conditional matches?

2 Answers 2

3

Try this:

RewriteEngine On RewriteRule ^/node/?$ - [F] RewriteRule ^/node/[0-9]+$ - [F] 
Sign up to request clarification or add additional context in comments.

1 Comment

There is a time limit before answers could be accepted.
1

You can write RewriteRul to send 403 as follows.

.htaccess

RewriteEngine On RewriteRule ^node/?$ - [F] RewriteRule ^node/[a-zA-Z/]*[0-9]+[a-zA-Z/]*$ - [F] 

This will work for,

www.clientsite.com/node/add -> Allowed

www.clientsite.com/node -> Denied

www.clientsite.com/node/72 -> Denied

As well as some extra features you might like,

www.clientsite.com/node/add/another/parameter -> Allowed

www.clientsite.com/node/add/another/72/param/ -> Denied

1 Comment

Read the question. /node/some-link-text needs to be allowed. This will block it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.