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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:55:52+00:00 2026-06-02T15:55:52+00:00

I want everything to be redirected to index.php, so I thought this should work:

  • 0

I want everything to be redirected to index.php, so I thought this should work:

RewriteEngine on
RewriteRule ^(.*)$ /index.php?url=$1 [L]

..but it doesn’t. This very similar RewriteRule does work though:

RewriteEngine on
RewriteRule matches/(.*) /index.php?url=$1 [L]

I later found out that to make the first one work you need:

RewriteCond %{REQUEST_FILENAME} !-f

Can someone please explain why the last RewriteCond is needed in the former example but not the latter?

  • 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-02T15:55:54+00:00Added an answer on June 2, 2026 at 3:55 pm

    Because first rule will rewrite already rewritten URL.

    RewriteRule Last [L] flag not working?

    For example:

    • Original request: /hello/pink-kitten
    • 1st (initial) rewrite: /index.php?url=hello/pink-kitten
    • 2nd cycle: rewritten to /index.php?url=index.php
    • 3rd cycle: rewritten to /index.php?url=index.php
    • No more cycles, as 3rd cycle produced the same result as 2nd

    Why rule works if added that condition? Because the condition clearly says — only do rewrite if requested URL is not file. Therefore, on 2nd cycle URL will not be rewritten again as /index.php is a file, therefore no more cycles.

    Why 2nd rule works just like that? Because it already has condition built in — URL should contain matches/ in it, and rewritten URL /index.php?url= as you can see has no matches/ part in it.

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

Sidebar

Related Questions

When I want to implement ViewModel I should cut everything c# code from my
i want to make a php app that let people submit photos/videos/sounds Now, everything
I want to setup jetty with jetty-blazeds extension. Everything looks fine but when I
I want to write a MobileSubstrate ( http://www.iphonedevwiki.net/index.php/MobileSubstrate ) addon that takes every HTTP
I want to move all my web site files (even including index.php) into a
I wan't to redirect everything to index.php exepept if a file or directory exists.
I've spent my weekend programming a little April Fool's joke, but it doesn't work
This issue is very likely codeigniter specific. I have a controller called redirect.php that
I want to redirect all requests to my index.php script in such a way
I have a site and I want to redirect everything to /index.html. I'm replacing

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.