Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6339781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:42:44+00:00 2026-05-24T19:42:44+00:00

I have a directory structure like this Root Sub Dir A Content Admin And

  • 0

I have a directory structure “like” this

  • Root

    • Sub Dir A
    • Content
    • Admin

And I have some files in Admin that I need to .htaccess forbid. I know they should be outside the root but in this situation I cannot. What is the correct syntax for htaccess to redirect a direct request for say ‘Sub Dir A/Admin/abc.php’ (say a forbidden file) back to say Sub Dir A/Admin/index.php – just an example. To note “abc.php” may be an include so it should only be a direct request. Oh forgot to ask, which directory to put the .htaccess file in

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:42:46+00:00Added an answer on May 24, 2026 at 7:42 pm

    If you really want to do this with mod_rewrite, then the rule can be:

    Options +FollowSymLinks -MultiViews
    RewriteEngine On
    
    RewriteRule ^abc\.php$ http://www.example.com/subdir_a/admin/index.php [R=301,L]
    

    This will issue 301 Permanent Redirect if you attempt to access abc.php directly.

    This is to be place in .htaccess in /subdir_a/admin/ folder.

    If you wish — you can place it in .htaccess file in website root folder — then alter rewrite rule a bit to include the path to abc.php:

    RewriteRule ^subdir_a/admin/abc\.php$ http://www.example.com/subdir_a/admin/index.php [R=301,L]
    

    Alternatively you can issue 403 Access Denied response:

    Options +FollowSymLinks -MultiViews
    RewriteEngine On
    
    RewriteRule ^abc\.php$ - [F,L]
    

    The common practice is not to relay on .htaccess and mod_rewrite (that can be unavailable on some shared hosting plans or disabled for performance reasons) and use PHP-Script side checks:

    1. To be placed in included/protected file (e.g. abc.php):

    if (!defined('ENTRY_POINT_MARK')) {
        header('HTTP/1.1 403 Access Denied', true, 403);
        exit();
    }
    

    2. To be placed in calling/master script (that you can access directly):

    define('ENTRY_POINT_MARK', 'EntryPointMark');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a directory structure that looks like this: /a/f.xml /b/f.xml /c/f.xml /d/f.xml What
I have a directory structure like this: root folder1 abc.json def.json somedir more.json folder2
I have a directory structure like this: - Root - Versioned deployment folder -
I have my directory structure like this: root/ sift/ __init__.py sift_descriptors.proto sift_descriptors_pb2.py project/ __init__.py
When creating gems, I often have a directory structure like this: |--lib |-- helpers.rb
I am a beginner in SVN.I have the SVN directory structure like this: |-trunk
I have a directory structure of directories and files that I want to render
How can I serve some static content in liferay? I have a directory structure
I have this directory structure. In my project root directory I have a main
I have a project with a directory structure that looks like: /foo/baz/__init__.py /bar/foo.py /bar/splat.py

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.