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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:24:50+00:00 2026-05-18T20:24:50+00:00

I was wondering what does the following mod_rewrite code do, can someone explain the

  • 0

I was wondering what does the following mod_rewrite code do, can someone explain the code in detail?

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
  • 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-18T20:24:51+00:00Added an answer on May 18, 2026 at 8:24 pm

    Line by line interpretation:

    RewriteRule .* index.php [L]
    

    Will be interpreted first and match every request (matched against the part of the URL after the hostname and port, and before the query string). .* is a regular expression to match all the time. A better and faster rule might be:

    RewriteRule ^ index.php [L]
    

    ^ in regex means, match every string that has a beginning. This is equal to .* -> match every thing.

    After a match was found, the processing will continue with the RewriteCond(itions).
    The two RewriteConditions are chained by a invisible logic AND. This block will only match if both RewriteConditions are true.

    RewriteCond %{REQUEST_FILENAME} !-f # Check if given file is not a file AND 
    RewriteCond %{REQUEST_FILENAME} !-d # Check if given directory is not a file and 
    

    Example: If you’ll have the following file structure on the server.

    .
    |-- css
    |   `-- base.css
    |-- img
    |   `-- logo.png
    `-- index.php
    

    If you request the URL example.com/css/base.css the following steps will happen.

    1. Match for RewriteRule (match all the time)
    2. Won’t match RewriteCond %{REQUEST_FILENAME} !-f, because css/base.css is a file.
    3. RewriteRule will be skipped because no match occurred, processing will test other rules and conditions*

    If you request the URL example.com/en/about the following steps will happen.

    1. Match for RewriteRule (match all the time)
    2. Match RewriteCond %{REQUEST_FILENAME} !-f, because en/about is no file.
    3. Match RewriteCond %{REQUEST_FILENAME} !-d, because en/about is no directory.
    4. Combination of RewriteRule and RewriteCond created a positive match ->
    5. Redirect the request to index.php with the flag L

    The flag L means last rule, which will stop the processing. More on flags.

    This rule combination is often used to redirect all request to an single entry point of an web application. To avoid serving static content by index.php, files and directories will be served by web server and not by the index.php. The dispatching of the dynamic site request will be done inside the logic of index.php.

    * The correct data flow can be found here

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

Sidebar

Related Questions

I was wondering what does the following mod_rewrite code do, can someone explain the
I've seen the following often lately and I'm wondering what it does? I can't
I keep wondering how does a debugger work? Particulary the one that can be
I am wondering why the following does not work in GNU Smalltalk: Object subclass:
I'm struggling with the following bit of code(/challenge) and I was wondering what would
I was wondering what does X11cairo in the following mean > pdf(1_4.pdf) > plot(output)
Can someone explain what exactly is happening at a low level / memory management
I was wondering what does the following sentence mean in laymens terms about the
I have the following code, which does work: var dataSource = (from p in
I'm wondering if anyone can shed some light on the following issue with Matlab

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.