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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:46:13+00:00 2026-05-31T14:46:13+00:00

I have an application that routes all requests through index.php . Here’s my setup:

  • 0

I have an application that routes all requests through index.php.

Here’s my setup:

  1. I access the application at http://www.example.com/sample/
  2. On the filesystem, the application sits in /home/chris/www/sample/
  3. The web-accessible directory of the application lives at /home/chris/www/sample/app/web.
  4. The DocumentRoot is set to /home/chris/www

/home/chris/www/sample/.htaccess is configured as follows:

RewriteEngine on

RewriteCond   %{REQUEST_URI}    ^/sample/(.+)$
RewriteCond   %{DOCUMENT_ROOT}/sample/app/web/%1  -f
RewriteRule   ^/sample/(.*)$    %{DOCUMENT_ROOT}/sample/app/web/%1 [L]

RewriteRule   ^(.+)$            index.php?ws_page=$1 [L,NC,QSA]

I’ve tried multiple configurations, but haven’t figured out why I keep getting 404’s on calls to “real” files.

Sample 404:

`http://www.example.com/sample/_css/960/reset.css`

(which I want to have rewritten to /home/chris/www/sample/app/web/_css/960/reset.css)

EDIT

I have already tried

RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteCond %{REQUEST_URI} !-l

and they did not work, because the %{REQUEST_URI} prefix does not match the filesystem prefix of these files.

EDIT 2

To clarify, I want requests of the form

`http://www.example.com/sample/foo/bar`

to be rewritten to the filesystem object /home/chris/www/sample/app/web/foo/bar, but only if that filesystem object exists.

  • 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-31T14:46:14+00:00Added an answer on May 31, 2026 at 2:46 pm

    One of the biggest bear-pits in reading the mod_rewrite documentation in the difference in behaviour in a system (that this the main and vhost configs that apache reads on start-up and those directive processes in a per-directory context. See the Per-directory Rewrites subsection of the RewriteRule documentation for further details.

    When using the rewrite engine in .htaccess files the per-directory prefix (which always is the same for a specific directory) is automatically removed for the RewriteRule pattern matching and automatically added after any relative (not starting with a slash or protocol name) substitution encounters the end of a rule set. See the RewriteBase directive for more information regarding what prefix will be added back to relative substitions.

    and later

    The removed prefix always ends with a slash, meaning the matching occurs against a string which never has a leading slash. Therefore, a Pattern with ^/ never matches in per-directory context. What you’ve done is to code around this.

    Incidentally, this is why it is always safer to specify a RewriteBase, as the engine gets this wrong without this.

    BTW, this second quote can be wrong because the prefix add-back occurs at the then of the rule set execution, and if you have a successful rule which is to a different relative branch (that is the target starts with a /) but without the [L] flag set, then the engine falls through to any subsequent rules with a leading / set. Most confusing, so my general advice is never rely on fall-through rules. Always force an immediate internal or external redirect on a successful substitution in a per-directory context as the engine has this and a couple of other bugs in this fall-through processing.

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

Sidebar

Related Questions

I have a Pyramid app that I've been developing and viewing locally through http://localhost:6543
I have an htaccess rewrite setup in my PHP application to route files via
Ok here is the problem in brief. I do have a pyramid setup that
I have a custom routing application that takes information for a route from google
I have application that makes different queries with different results so the caching in
I have application that is connecting to the DB and if I enter incorrect
I have application that is up more than 3 days. I can see in
I have application that brings response via Ajax and creates 5-20 new jQuery click
I have an application that sends messages to an external web service. I build
I have an application that displays an image inside of a Windows Forms PictureBox

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.