Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have another PHP application in a folder named app inside my Wordpress installation, and I need to disable all Wordpress rewrite rules for that folder and it's content. So that when I go to www.domain.com/app I get my application page, instead of the standard Wordpress 404 page.

I know this is pretty basic apache rewrite rules, and i searched for this, tried some things and didn't work well.

Almost forgot, i need to do this only by editing Wordpress htaccess file. And the app has it's own htaccess file.

Thanks.

EDIT: htaccess content

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

EDIT: Application htaccess

DirectoryIndex index.php
<FilesMatch "\.(php|inc)$">
Order allow,deny
deny from all
</FilesMatch>
<FilesMatch "(index.php|download.php)$">
Order allow,deny
allow from all
</FilesMatch>

These rules don't do much, they basically deny access to all PHP and INC file types, except index.php and download.php. Which are the ones the user needs to access, the rest of them are classes used internally by PHP.

EDIT 3: Resolution:

As it turns out, there was nothing wrong with the Wordpress htaccess or the application, after turning error reporting on remote hosting server, PHP reported a corrupted file, once replaced, all started to work well. My thanks to Wietse Venema for the suggestion.

share|improve this question
    
@Fábio: Can you also give us the .htaccess rules from the app? Is it a public app, or developed on top of a public framework (something we can know)? –  Jan Fabry Mar 4 '11 at 16:36
    
@Jan Fabry: Sure just a second. The application doesn't use any Framework, was built from scratch, just for kicks and to keep good habits. –  Fábio Antunes Mar 4 '11 at 17:05
    
if you go to www.domain.com/app/index.php, do you also get the Wordpress 404? –  Wietse Venema Mar 4 '11 at 18:19
    
@Wietse Venema: Any other location inside 'app' reports Wordpress 404, in case of the index.php, I just get a blank response. Like there was nothing inside the file to be processed. –  Fábio Antunes Mar 4 '11 at 18:48
1  
It might be that is actually is being executed, but it throws an error that you don't see. Try reading your errorlog or put ini_set('display_errors', 1); error_reporting(E_ALL); just after the opening <? of your index.php. –  Wietse Venema Mar 4 '11 at 21:38
show 3 more comments

1 Answer

up vote 5 down vote accepted

The default .htaccess-file will already support the behaviour you want;

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

The magic is in the lines that start with RewriteCond. They instruct Apache to apply the rule RewriteRule . /index.php [L] (which means "any URL will go to index.php"), only when the URL is not an existing file !-f or existing directory !-d.

So this should work by default. The Wordpress rewrite rules do not apply when you try to visit an already existing file.

share|improve this answer
    
Of course, if the app also uses rewrites to map non-existing URLs to itself, this will not work. Then you need a specific condition that the URL should not start with app/. –  Jan Fabry Mar 4 '11 at 16:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.