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

  • Home
  • SEARCH
  • 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 7024457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:50:31+00:00 2026-05-27T23:50:31+00:00

I want to make it impossible for users to access a certain scripts running

  • 0

I want to make it impossible for users to access a certain scripts running on my server.

The best way i can explain this is by explaining a brief description of how the root level of the website works.

ROOT contains 4 scripts:

index.php
home.php
error.php
results.php

In the index file, i have included and directed the user to these 3 files, on certain instances.

Now, this causes a bit of a problem, as the index file includes the neccessary controllers and any addittional scripts before the new script is included and the users’ point of view changes to the new “webpage”. I have done this as it provides a very quick experiance for the user, as in the the page load times have become very low.

Now these files have been set with the robots no index meta, and are removed from the sitemap. I want to go one step further, and make it impossible for users to access these scripts direcly, as in by typing http://www.mysite.com/results.php

This is because if they do they are greeted with an ugly, unfuctional page that has not had the layout variables, or main css stylesheet defined.

Here is a brief outline of index.php:

<?php
ob_start();

$activeHome = 'active';

require_once $_SERVER['DOCUMENT_ROOT'] . '/../../includes/config.php';
require_once($docRoot . '/includes/layout.php');

...

include 'home.php';
?>

This script includes any code that configures the 3 other scripts. as in

if (isset($_GET['register']))
{
header('Location: http://www.mysite.com/register/');
exit();
}

And here is the same for home/results/error.php

<?php

....

echo $head1 . $pageDetails . $head2 . $header .  $pageContent . $footer;
exit;
?>

In these scripts all of the varibles except for pageDetails and pageContent are defined in the layout script, along with the main css file.

So as you can see by the setup of this website, i do not have very many options left, unless to restrict these pages by a php function which i presume would be fairly complex and more than likely over my head… I assume it would involve heavy use of global or session variables, which is not something i am all to keen about. An easier way, i thought, would be to do this via the htaccess file. But i am not all that knowlegable when it comes to htaccess commands, and i am not so sure if this is even possible going that route.

Would anyone with a bit more knowledge on something like this, like to offer their opinion or any input or advice?

  • 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-27T23:50:31+00:00Added an answer on May 27, 2026 at 11:50 pm

    You have two choices.

    1. Move the files outside of the web root – This logically makes more sense. If the files aren’t meant to be accessed by the web server they should be outside of the web root. This would be the preferred method as long as you (and the web server’s user and group) have access to the directory that contains your php scripts. It is also more preferable because you don’t need Apache specific (or even mod_rewrite specific) .htaccess rules so this will be portable to most other server flavors. A sample directory structure might looks like this:

    /
        /www
            /index.php
        /includes
            /home.php
            /error.php
            /results.php
    

    Just make sure that your webserver’s user has access to www and includes and your webserver configuration allows you to work outside of your web root (most apache configurations only allow you to work within it).

    2. Add htaccess rules to prevent those from being accessed – This is less preferable. If you want to be stubborn or you have a legitimate reason for keeping the files in your web root, this would be the way to do it on Apache.

    RewriteEngine On
    RewriteRule ^(home.php|error.php|results.php)$ - [L]
    

    To prevent users from accessing /register/register.php:

    RewriteEngine On
    RewriteRule ^register/register.php$ - [L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make sure people can't type the name of a PHP script
As far as I can tell, it is impossible to access the content of
my problem is, I want to create a new folder and make it impossible
Is there a way I can make class decorators work on Google App Engine
I have this problem: My web application has a form where the users can
I want to make Activity like this using GridView. And this Activity have only
Forgive me if this sounds impossible, I am new at CSS. I want to
I want make datetimepicker in my project. Using jquery how it is possible? I
Let's say I want make some of my sources publicly available via my blog
I have style sheet with a class name changebackgroundcolor i want make change in

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.