skip to Main Content

I am trying to redirect people, that try to access a specific folder on web to receive 404
Example: if anyone wants to access www.mysite/myfolder/ I wish that person to receive 404 error
What I have tried by now:

RewriteCond %{REQUEST_URI} ^/node/$
RewriteRule .* - [F]
RedirectMatch 301 www.yoursite/node/


RewriteEngine on
RewriteRule ^//node/123 /node/999 /node/128173/(.*)$ /pages/errors/404.php$1 [R=301,L]

None of those really worked-received 500 error
Also tried to simply redirect everything to a non-existent site, like this:

Options +FollowSymLinks
RewriteEngine On
Redirect 301 /node/*.*   http://www.your imaginary site/to-new-url

Yet, still received 500
Can anyone please help?

2

Answers


  1. Chosen as BEST ANSWER

    Hi all and thank you for answering my 500 error was apparently due to not specifying https in the redirect form After that everything worked


  2. Why not deny access to /node/ folder?

    <Directory /node/>
      Deny from all
    </Directory>
    

    or modify your rewrites in .htaccess to:

    RewriteEngine on
    RewriteCond %{REQUEST_URI} ^node/ [NC]
    RewriteRule (.*) /pages/errors/404.php [R=301,L]
    

    But it’s not good practice, 404 page should return HTTP 404 status not HTTP 301 as redirect.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search