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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:49:54+00:00 2026-06-14T08:49:54+00:00

How can I redirect via .htaccess file, that only the index.html can be accessed

  • 0

How can I redirect via .htaccess file, that only the index.html can be accessed via URL.
I already got this:

RewriteEngine on
RewriteBase /
Options +FollowSymlinks

RewriteRule ^/?login/?$ /php/login.php [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.html [L,QSA]

It works fine if somebody types in for example “www.mypage.com/skd/lasnd”
but if somebody types in a file which exists on the webserver, e.g. “www.mypage.com/php/login.php”, he will be redirected to that page. How to forbid that?

To be more exact: my JavaScript & PHP scripts should be still allowed to access to every file on my webserver.

  • 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-06-14T08:49:56+00:00Added an answer on June 14, 2026 at 8:49 am

    These lines:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    

    are conditions “if REQUEST_FILENAME is NOT a file, if REQUEST_FILENAME is not a directory” and if both are met then RewriteRule is taking place. This is usually to allow “friendly urls” to work and at the same time to not rewrite any images, css etc. You can block access to files with many ways, but you have to take care to not block too much (like said images etc). The simplest approach would be to put your files in subdirectory and add another .htaccess file in that directory with line

    Deny From All
    

    This will make httpd reny any request to whatever is in that directory and subdirectories (unless another .htaccess overwrite these rules) while your scripts will be able to access them without a problem.

    I strongly recommend do read mod_rewrite docs

    EDIT

    There’s no “my javascript” and “their javascript”. There’s request and that’s all you can tell for sure. You cannot tell which access yours and which is not. “i only want to deny request via typing in the browser adress line” – you can’t tell that either. You theoretically could check REFERER, and if there’s none set then assume it’s direct hit, but REFERER comes from browser so it can be faked as well. And I personally block all REFERERS by default, so all my requests are w/o any REFERER even these not direct. You could try cookies, but again – these can be be grabbed by script and sent back too. The only real option is to Deny from all to these files and “tunel” them thru some sort of script (i.e. PHP) that would do i.e. file() on target file only if user authenticated himself previously using login and password. Any other attempts are broken from the start.

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

Sidebar

Related Questions

how can i redirect index.php?search= to the base url? I tried it with this
How can I redirect someone who types http://domain.com/+abc (this should only apply to alphanumeric
I need web page to redirect via HTML meta and open that page in
I need to redirect a single Wordpress URL that is formatted like this: www.bluewidgets.com/?p=123
How can I redirect the following via a virtual host: http://www.surveys.abc.com/index.php?sid=14414&newtest=Y&lang=en to http://www.abc.com
I'm already redirecting an old domain via a 301 redirect but I've noticed that
Is there a .htaccess script I can use to redirect the url of an
Is there a .htaccess script I can use to redirect the url of an
I have a url redirect controller called go. It can redirect topic model and
How can I redirect to current url after logout? HTLM for logout: <a href=<?php

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.