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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:33:01+00:00 2026-06-09T22:33:01+00:00

I have the following .htaccess in the root folder of a web application: RewriteEngine

  • 0

I have the following .htaccess in the root folder of a web application:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^\.(.*) [NC]
RewriteRule ^(.*) http://%1/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?req=%{REQUEST_URI}&%{QUERY_STRING}

This works as I want with one exception: if the directory actually exists, that directory is served rather than the request being passed of to the PHP script.

So if directory /docs/ exists, the index.htm is sent to the browser whereas a request for the directory /doesnotexist/ which doesn’t exist will be handed to the PHP script.

Any ideas how I can amend this so that ALL requests are handed off to PHP regardless of whether the location exists or not?

  • 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-09T22:33:03+00:00Added an answer on June 9, 2026 at 10:33 pm

    Your second set of conditions constrain matching requests to not point to an existing file nor an existing directory. That’s why when you browse to /docs/ and the directory exists the rule won’t fire.

    All you need to do to fix this, is to get rid of the second rewrite condition. This let’s the rule beneath it fire on any request that does not point to an existing file. If, indeed, what you want is to redirect every request to the PHP script, then the first rewrite condition needs to be eliminated as well.

    RewriteCond %{REQUEST_FILENAME} !-f
    # RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^.*$ index.php?req=%{REQUEST_URI}&%{QUERY_STRING}
    

    Note that the # uncomments the line so it won’t get picked up by mod_rewrite.

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

Sidebar

Related Questions

i have following .htaccess RewriteEngine On DirectoryIndex index.php RewriteRule ^([a-zA-Z0-9_-]{3,20})/([^/]+)/([^/]+)?$ index\.php?page=$1&s=$2&o=$3 [L] RewriteRule ^([a-zA-Z0-9_-]{3,20})/([^/]+)?$
I have the following .htaccess config RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^example.com [NC]
I have the following .htaccess file in the root of my application: RewriteEngine On
i have the following .htaccess RewriteEngine On RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?type=Navigation&action=$1 RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?type=Navigation&action=$1 Options
I have the following .htaccess file in a directory: RewriteEngine On RewriteCond %{HTTPS} !=on
I currently have the following htaccess rewrite rule: RewriteRule (.*) index.php/$1 [L] How do
I have the following in a .htaccess file redirect 301 /page.php http://domain.com/page Which works
I have placed .htaccess file in my server's root folder with following content: Redirect
Let's say we have the following schema: root/ application/ -public/ index.php css/ img/ javascript/
I have a website with the following files in the root folder: index.wml index.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.