Page 2 of 2

Posted: Thu Oct 06, 2005 8:46 pm
by Hathor
I found a solution for this after a LOT of trial and error and searching online. It's almost embarrassingly simple. And it works not just between Serendipity and other apps... almost any two php scripts, one in a subfolder under the other, can have clashing rewrite rules.

My serendipity blog is in the main folder at BlueMushrooms.com. The rewrite rule I had added in was this:
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^bluemushrooms\.com$
RewriteRule (.*) http://bluemushrooms.com/$1 [R=301,L]
That makes it so that if people type "www.bluemushrooms.com", it will load as "bluemushrooms.com". This may not matter to average bloggers, but if you want your site to rank well in Google, it's very important, because Google counts the www and non-www version as two domains and penalizes you. (Which is, IMHO, ridiculous, but what can ya do?)

Now, the PROBLEM was, I had a directory in a subfolder. S9's rewrite rules were clashing with the subfolder's rewrite rules, so I had no choice but to put a "RewriteEngine Off" in the subfolder's htaccess. Still with me? :)

But that meant people typing in "www.bluemushrooms/directory" would get the www version, which is not a Google happy situation.

Here's the solution. This is the htaccess in my SUBFOLDER that makes everything work. Notes in red explain step by step what's being accomplished:
RewriteEngine Off (turns off S9's clashing rewrite rules)
#lmasetting (settings the subfolder script needs to function)
<files directory>
ForceType application/x-httpd-php
</files>
#lmasettingend

RewriteEngine On (turns rewrite back on for subfolder)
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^bluemushrooms\.com$
RewriteRule (.*) http://bluemushrooms.com/[b]directory/[/b]$1 [R=301,L]
(this is the key line that tells it where to redirect people who use "www". By sticking my subfolder at the end (bold), each folder gets the appropriate redirection to work the way I want)

RewriteEngine Off Not Working

Posted: Sat Oct 22, 2005 11:04 am
by mark_macinnes
I've been trying to use a subdirectory without the blog from redirecting me. I've created a .htaccess file in the subdirectory. It's contents are:
RewriteEngine Off

But this isn't working.

This is the link:
http://www.awake-and-dreaming.co.uk/test/

Re: RewriteEngine Off Not Working

Posted: Mon Oct 24, 2005 12:04 pm
by garvinhicking
What file are you requesting in your /test/ subdirectory? Di dyou put a index.html there, or what?

Regards,
Garvin

Posted: Mon Oct 24, 2005 12:13 pm
by mark_macinnes
I was requesting a index.html file.

I've changed from using mod_rewrite to using Apache errorhandling and everything is working fine now.