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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:12:37+00:00 2026-05-24T02:12:37+00:00

I have been trying to accomplish the same as many frameworks do: having the

  • 0

I have been trying to accomplish the same as many frameworks do: having the request processed by a .php (namely, index.php), while keeping a /application/public folder which contains all the elements that should be shown in case they exist. For example:

folder /application/public
total 28K
92897619 drwxr-xr-x 5 1001 1001 4.0K Jul 29 00:07 .
92897616 drwxr-xr-x 7 1001 1001 4.0K Jul 28 23:31 ..
92897754 -rw-r--r-- 1 1001 1001   15 Jul 29 00:07 .htaccess
92897733 drwxr-xr-x 2 1001 1001 4.0K Jul 28 23:31 images
92897620 -rw-r--r-- 1 1001 1001  696 Jul 28 23:58 index.php
92897625 drwxr-xr-x 2 1001 1001 4.0K Jul 28 23:31 javascript
92897734 drwxr-xr-x 2 1001 1001 4.0K Jul 28 23:31 stylesheets

folder /:
total 24K
92831996 drwxr-xr-x 4 1001 1001 4.0K Jul 29 02:44 .
91980897 drwxr-xr-x 5    0    0 4.0K Jul  6 00:30 ..
92831975 -rw-r--r-- 1 1001 1001  360 Jul 29 02:44 .htaccess
92897616 drwxr-xr-x 7 1001 1001 4.0K Jul 28 23:31 application
92832733 -rw-r--r-- 1 1001 1001  696 Jul 29 00:02 index.php
92897739 drwxr-xr-x 6 1001 1001 4.0K Jul 28 23:31 system

If there is a request for example.com/images/a.jpg, /application/public/images/a.jpg should be shown, as it exists. Otherwise, index.php would get ?uri=images/a.jpg as query string.

With this in mind, I wrote the following .htaccess (placed at /):

Options +FollowSymLinks +Indexes
RewriteEngine on
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}/application/public%{REQUEST_URI} -f
RewriteCond %{DOCUMENT_ROOT}/application/public%{REQUEST_URI} -d
RewriteRule ^(.*)?$ application/public/$1 [L]
RewriteRule ^(.+)?$ index.php?uri=$1 [PT,QSA,L]

Still, requesting for anything existent at /application/public redirects the request to index.php (for example, example.com/images/a.jpg ends up being example.com/index.php?uri=images/a.jpg).

Apache logs only show the following (when requesting example.com/javascript/index.php):

File does not exist: /home/jbayardo/www/test/javascript

This, as you can imagine, leaves me in the blank.

  • 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-24T02:12:37+00:00Added an answer on May 24, 2026 at 2:12 am
    1. Add [OR] at the end of first RewriteCond line.

      Currently the logic is AND: currently it reads as “if it is a file that exists AND if it is a folder that exists” .. which cannot be true — conditions are not satisfied and rewrite does not occur.

      You need “if it is a file that exists OR if it is a folder that exists”.

      See docs: http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond (you have to scroll down a bit).

    2. Even if rule #1 will work properly, it will still end up rewritten to index.php?uri=$1 — because that what you are telling Apache to do. You need to add a condition to prevent rewriting already rewritten URLs (keep in mind, that when Apache rewrites URL, it goes to next iteration ans start matching all rules again from top — that is how it works).

    3. The ? in RewriteRule patterns are not needed.

    This is how I see it:

    Options +FollowSymLinks +Indexes
    
    RewriteEngine on
    RewriteBase /
    
    RewriteCond %{DOCUMENT_ROOT}/application/public%{REQUEST_URI} -f [OR]
    RewriteCond %{DOCUMENT_ROOT}/application/public%{REQUEST_URI} -d
    RewriteRule ^(.+)$ application/public/$1 [L]
    
    RewriteCond %{REQUEST_URI} !^/(application/public/|index.php)
    RewriteRule ^(.*)$ index.php?uri=$1 [PT,QSA,L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first time trying to accomplish core data and been having some
Recently, I have been trying to accomplish creating a full-width jQuery slider that would
I have been trying to figure this out, but couldn't. On php a multidimensional
I have been trying to implement Win32's MessageBox using GTK. The app uses SDL/OpenGL,
I have been trying to find a really fast way to parse yyyy-mm-dd [hh:mm:ss]
I have been trying to determine a best case solution for registering a COM
I have been trying to work my way through Project Euler, and have noticed
I have been trying to get around this error for a day now and
I have been trying to explain the difference between switch statements and pattern matching(F#)
I have been trying to read a picture saved in Access DB as a

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.