How to turn off certain conditions for specific folders ?

Oh, the strange things mod_rewrite does!

How to turn off certain conditions for specific folders ?

Postby Iron » Mon Apr 20, 2009 1:18 pm

Hi,

I have a "weird" problem here with some of my mod_rewrite rules.

My main .htaccess file located in my domain root includes a lot of rewrite rules and these 2 rules:

AddHandler x-httpd-php .php .htm .html

--> parses .html files as .php files

Options +FollowSymLinks -MultiViews -Indexes

--> I have no exact idea what the last set of rules do but after some research I found out that they needed to be implemented to make my rewrite rules work on my GODADDY server

Now since then I could not make index.php files work, but that was never an issue since I just renamed them to index.html.

All other .php files, e.g. "test.php" work fine.

Here's my problem:

I just implemented a Mapquest API, which needs me to include a ton of .php files via the PHP require_once() statement.

The server started giving me a PHP Parse error, which implemented a problem with the PHP statement "instanceof".

Since "instanceof" requires PHP 5 which I am running I found out after some trial and error that the mod_rewrite rules cause the problem.

After turning off "Options +FollowSymLinks -MultiViews -Indexes", the Mapquest API works, but of course my rewrite rules do not work anymore.

Here's my question:

Since this rule "Options +FollowSymLinks -MultiViews -Indexes" is in my main .htaccess file, is it possible to TURN OFF this rule for a specific folder ?

The Mapquest API is in a dedicated folder and all pages using it are in the same folder, so I figured turning off these rules for this specific folder would solve the problem...

Is is possible to turn certain rules off for a specific folder ?

Thanx for your help in advance !!!

Regards,
Mike
Iron
 
Posts: 4
Joined: Mon Apr 20, 2009 12:48 pm

Postby richardk » Mon Apr 20, 2009 2:18 pm

My main .htaccess file located in my domain root includes a lot of rewrite rules

What is your mod_rewrite? Maybe there's a problem with it.

and these 2 rules:

AddHandler x-httpd-php .php .htm .html

--> parses .html files as .php files

Options +FollowSymLinks -MultiViews -Indexes

--> I have no exact idea what the last set of rules do but after some research I found out that they needed to be implemented to make my rewrite rules work on my GODADDY server

AddHandler and Options are directives from mod_mime and the Apache core respectively.

You probably only need
Code: Select all
Options +FollowSymLinks

to make mod_rewrite work.

Now since then I could not make index.php files work, but that was never an issue since I just renamed them to index.html.

Do you mean it does not show the /abc/index.php file when you visit /abc/? If so, you should try the DirectoryIndex directive
Code: Select all
DirectoryIndex index.php index.html


Since this rule "Options +FollowSymLinks -MultiViews -Indexes" is in my main .htaccess file, is it possible to TURN OFF this rule for a specific folder ?

It's three seperate settings. + means turn on, - means turn off.
Code: Select all
# Do follow Symbolic Links.
Options +FollowSymLinks
# Don't search for more appropriate version of the requested content.
Options -MultiViews
# Don't show a file listing when there is no index file.
Options -Indexes

You could try
Code: Select all
Options -FollowSymLinks

and/or
Code: Select all
RewriteEngine Off

in the sub directory .htaccess file.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Iron » Thu Apr 23, 2009 1:38 pm

Richard,

thank you or your answer !

Regarding the index.php files:

I meant that after I placed "AddHandler x-httpd-php .php .htm .html" in the .htaccess file, every time I try to access an index.php in one of my sub folders I get redirected to my main domain --> http://www.domain.com

The index.html files work without a problem in my sub folders.

That's why I said it was never a real problem, I just renamed the index.php files to index.html.

--> all other .php files work well, e.g. test.php

Now regarding my problem, I found a solution - which I consider a fix, but it works fine for now, here's what I did:

1. I placed these commands in the .htaccess file in my subfolder:

Options -FollowSymLinks
RewriteEngine Off

2. I had to rename the index.html to index.php to make it work

--> it did not work with index.html but after I renamed the file to index.php it worked

--> I do not get redirected to my domain root anymore when accessing the index.php file

I am assuming that when including the Mapquest API files (all .php files), that it did not work b/c the index file in my sub folder (that includes the Mapquest API files) was index.html and that's why PHP gave me the Parse error when processing the "instanceof" function.

Thanx for your help !!!

Mike
Iron
 
Posts: 4
Joined: Mon Apr 20, 2009 12:48 pm

Postby richardk » Fri Apr 24, 2009 11:15 am

What is your mod_rewrite?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Iron » Fri Apr 24, 2009 1:58 pm

Richard,

just to make sure I give you the right info:

Do you mean the mod_rewrite I use to rewrite the urls ?

Mike
Iron
 
Posts: 4
Joined: Mon Apr 20, 2009 12:48 pm

Postby richardk » Fri Apr 24, 2009 2:18 pm

Either you whole .htaccess file (from your document root) or all the Rewrite* lines from it (and anything else you feel is relevant).
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Idiosyncrasies

Who is online

Users browsing this forum: No registered users and 12 guests

cron