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 7601713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:13:54+00:00 2026-05-30T23:13:54+00:00

My document root is /var/www and I have no virtual hosts enabled. This is

  • 0

My document root is /var/www and I have no virtual hosts enabled.
This is my folder structure of /var/www:

index.php
classes (external)
controllers
models
files (img, js, css)
views (pages, components)

As you can see I am using a model view controller pattern. What I need now is the correct configuration I have to use in my httpd.conf to define that only the files folder can be accesed and no other folder, to prevent “Not found” messages or direct php access. How can I set this up?

This is my current httpd.conf

ServerSignature Off
ServerTokens Full

# Settings for server @ port 80.
<VirtualHost *:80>
    ServerName <url>
    DocumentRoot /var/www
    DirectoryIndex index.php

    # No one has access to the main directory.
    <Directory />
        Order Deny,Allow
        Deny from all
        Options None
        AllowOverride None
    </Directory>

    # Configure the main directory
    <Directory /var/www>

        # Everyone has access to the main directory.
        Order Allow,Deny
        Allow from all
        Options FollowSymLinks
        AllowOverride None

        # Enable clean urls.
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php/$1 [L]
    </Directory>
</VirtualHost>

Thanks for help 🙂

  • 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-30T23:13:55+00:00Added an answer on May 30, 2026 at 11:13 pm

    If possible, it would be ideal to keep your controllers, view scripts and other application related code out of /var/www and instead put it in /var/application or something like that.

    Then you don’t need any rewrite rules to deny access to everything but files. If you ever wanted to add access to a new folder (e.g. /var/www/css) then you will likely have to do something to make it accessible. Or you have the reverse situation where you explicitly deny the folders you don’t want accessed. That works but if .htaccess is ever broken or someone forgets the rules moving to a new server then you have more work to do.

    In index.php, define some constant that tells where the files live (e.g. define('APPLICATION_PATH', '/var/application');

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have DocumentRoot /var/www/test in my .htaccess file. This is causing the apache server
I have created a python web app with this directory structure: # cd /usr/local/www/myapp
I have a Zend Framework site in this dir /var/www/example.com/ and put the WP
I have a server where the public root is located at: /var/www/example.com/html/ . Using
I have a file like this <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/ <Directory />
it's all in index.php /* Define site root */ defined('DOCUMENT_ROOT') ? null : define('DOCUMENT_ROOT',realpath(dirname(__FILE__)));
I have the following config in my lighttpd.conf: $HTTP[host] == trac.domain.tld { server.document-root =
I have an XML document with a default namespace indicated at the root. Something
I have a server with several virtual hosts. Now I want to set up
I have setup up 2 virtual hosts that share the same IP on a

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.