Note that there are some explanatory texts on larger screens.

plurals
  1. POApache directory redirect and htaccess directory qsa
    primarykey
    data
    text
    <p>I've recently come across some strange behavior with directory requests in URLs on Apache servers. I'm fairly new to Apache servers and HTACCESS stuff, so maybe someone can fill me in about this.</p> <p>If there is a sub-directory called "example" on a server and I try to request this directory by typing www.example.com/example/ everything works as expected. The Apache server looks for the default.php, index.php, and others as expected. If I type www.example.com/test and there is no file or directory corresponding to "test" I get a 404 error as expected. Here's where it gets weird, if you type in www.example.com/example (and www.example.com/example/ exists) the server doesn't even return a 404. In fact it either redirect loops or I end up getting a "www.example.com/example does not exist or is not available." from my ISP. Is this suppose to happen?</p> <p>Here is where it is giving me a problem. I have a simple HTACCESS file that redirects all requests to a query string:</p> <pre><code>Options +FollowSymLinks +MultiViews -Indexes &lt;IfModule mod_rewrite.c&gt; RewriteEngine on RewriteBase / RewriteRule ^styles/[\d]{10}/(.*)\.(css|jpg|gif)$ styles/$1.$2 [NC,L] RewriteRule ^scripts/[\d]{10}/(.*)\.(js|jpg|gif)$ scripts/$1.$2 [NC,L] RewriteRule \.(css|jpe?g|png|gif|js|ico)$ - [L] RewriteRule ^(.+)$ default.php?page=$1 [QSA,L,NC] &lt;/IfModule&gt; </code></pre> <p>This works fine about 99% of the time. Then there is the directories issue I described above. Whether or not the HTACCESS is present, if a directory is requested without the ending slash, everything fails, and this occurs on both my local server and on my shared host with Godaddy. Thing is, I need the any and all requests such as </p> <blockquote> <p>www.example.com/example</p> </blockquote> <p>to go to </p> <blockquote> <p>default.php?page=example</p> </blockquote> <p>even if there is a directory </p> <blockquote> <p>/example/</p> </blockquote> <p>listed.</p> <p>Also, I've looked over the rewrite logs, if the directory is requested without the trailing slash, the Apache server doesn't even get a chance to process the HTACCESS file. </p> <p>Anyone have any solutions?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload