Forum Moderators: phranque

Message Too Old, No Replies

URL rewrite: excluding existing folder and file?

         

tntpower

6:08 pm on Apr 24, 2008 (gmt 0)

10+ Year Member



I have a lot of PHP files, for example, www.mysite.com/abc/hello.php

I installed Drupal at the root directory and I keep the abc directory.

In Drupal, I use URL path feature to set some nodes' URL like www.mysite.com/abc/bydrupal.php. The path, abc/bydrupal.php does not exist physically, it is just a feature provided by Drupal (through either htaccess or Drupal's own router, I am not sure).

The problem is that:

I still have some www.mysite.com/abc/file.php in abc folder. So I want visitors first visit fake URL that will be processed by Drupal. If such URL does not exist, then visit the physical file.php.

How can I do that via Apache URL rewrite?

Thanks,

Added:

I also need to bypass folders.

For example, while I have used Drupal to generate URL like www.mysite.com/abc, there is a physical directory www.mysite.com/xyz exist, and some files in xyz will be processed by drupal while others not; in some cases, /ABC will be regularly accessed while /ABC/file.foo will be processed by drupal.

By the way, for a real folder /example, www.mysite.com/example (or /example/) is going to be handed by Drupal, while /example/file.foo is a physical file and shall be visited normally.

Thanks,

jdMorgan

11:37 pm on Apr 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See the Apache mod_rewrite RewriteCond directive.

Be aware that using 'file exists' checks can add a significant load to your server. If possible, you should avoid doing this, as it will force you to upgrade to a VPS or dedicated server sooner rather than later.

If you must use a 'file exists' check, then be sure to qualify the check as much as possible -- Do not run the check until you are sure that the requested URL meets all other possible requirements, so you're sure it needs to be checked. In simple terms, use a very-specific RewriteRule pattern, and if multiple RewriteConds are used, place the 'file exists' check RewriteCond last.

Jim