Forum Moderators: phranque

Message Too Old, No Replies

Physical File > RewriteEngine?

I want RewriteEngine > Physical File

         

Laelsa

11:25 pm on Jun 5, 2007 (gmt 0)

10+ Year Member



If the Physical File exists then the RewriteEngine will not execute the file listed inline. In this case, "ht.php," instead it pulls the Physical File if it exists. I want the RewriteEngine to take precedence over the Physical File.

For example, if i type in "/bigFolder/smallFolder" AND those two folders exists, Apache will serve those real pages... I don't want this.

What I do want however, if i do "/fakeFolder/moreFolder" the RewriteEngine will execute "ht.php?first=bigFolder&second=smallFolder" because the structure doesn't exist.

I want everything to go thru "ht.php," even if the files exists.

Here's my test .htaccess code.

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([a-z]+)/([a-z]+)$ ht.php?first=$1&second=$2

Any ideas? I am, of course, open to other solutions.

-Lance

jdMorgan

2:05 am on Jun 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your mod_rewrite code does not check for 'file exists' so the problem is not something in the code, it's somewhere else.

Are you running Apache 2.0 or later? If so, disable AcceptPathInfo.
Also, add -MultiViews to your Options directive to disable content-negotiation if you're not using it.

See Apache core directives documentation for more info about these directives and how they may relate to your problem.

The only (minor) problem I see with the code is that your RewriteRule should have an [L] flag on it for the sake of efficiency.

Jim

Laelsa

6:25 pm on Jun 6, 2007 (gmt 0)

10+ Year Member



I added the -Multiviews, AcceptPathInfo off, and I am running Apache 2. Unfortunately, it hasn't change anything.

I still have yet to find a way to override the file system in favor of Rewrite.

-Lance

jdMorgan

7:42 pm on Jun 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you made the change in httpd.conf, did you restart your server after setting AcceptPathInfo off?

This is not "the filesystem" causing this problem. It is some other "active agent" such as an Apache module or another one of your scripts causing it. Look into any other mod_alias and/or mod_rewrite directives in httpd.conf, conf.d, any other configuration files included in those, and in .htaccess. Obviously, some directive is being applied before your rewrite code can run, and is diverting the request.

Jim