Forum Moderators: phranque

Message Too Old, No Replies

More htaccess problem

follow up to previous post

         

Clark

6:16 am on Aug 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I had a problem redirecting IP Address and was helped out in this thread:
[webmasterworld.com...]
but I just noticed that my subdirectories aren't following the instructions anymore.

In other words:
[domain.com...]
redirects to [domain.com...]

but
[domain.com...]
does NOT redirect to
[domain.com...]

I am using the exact code posted in that thread. There is an .htaccess in the subdirectory, which is required...does the second .htaccess cause the first one to be completely ignored?

jdMorgan

2:47 pm on Aug 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> There is an .htaccess in the subdirectory, which is required...does the second .htaccess cause the first one to be completely ignored?

It could, if it contains "RewriteOptions [httpd.apache.org] none".
Or it may be overriding the top-level .htaccess file's actions.

It is usual to answer a question like this with two questions:

1) Did the top-level rewrite code stop working at the same time that you changed or added something else?
2) What happens if you (temporarily) un-do that change?

Once you've established causality, discussion and remediation is much easier...

Jim

Clark

6:53 pm on Aug 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It doesn't have the code you mentioned, but it does have this at the top:
ReWriteEngine On
Options +FollowSymlinks -Indexes

(that's not the whole file, which I'm excluding of course..but I'll mark up a generic version of what it contains if you need it to answer the question)

1) Did the top-level rewrite code stop working at the same time that you changed or added something else?

I could have sworn that it (subdirectories) was working just fine before and after making the change..but maybe I just didn't test it properly. Basically, I'm not sure. What I do know happened is I updated cpanel. Maybe that could have done something?

2) What happens if you (temporarily) un-do that change?

Forgot to mention that undoing that change does not fix the problem.

Once you've established causality, discussion and remediation is much easier...

Indeed. I wish I could establish causality, but I just don't know for sure..

jdMorgan

7:35 pm on Aug 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Review your .htaccess file, and look for changes made by cPanel. I should warn you that continuing to use cPanel when you have custom code in your .htaccess file(s) is asking for problems, since both you and cPanel will be modifying the file, and cPanel often takes liberties with its .htaccess file modifications -- including deleting stuff.

Whether you continue to use cPanel or not, always keep backups of your .htaccess file, so that if you or cPanel clobbers some settings, you can copy them back.

Jim

Clark

9:33 pm on Aug 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



But doesn't the .htaccess file I've got on the domain itself override any .htaccess that happens by default?

jdMorgan

9:42 pm on Aug 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, rules in lower-level .htaccess files can override higher-level ones if the rules still apply after the higher-level code runs. If RewriteOptions is set to "none", then only the lowest-level rewrites will be applied, and the higher-level rules won't have any effect.

Jim

Clark

2:08 am on Aug 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Whooboy. I never dug too deeply into cpanel...any idea where to look if they made any changes?

Clark

2:46 am on Aug 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Scratch the cpanel question. I did some experimentation and the problem is not cpanel. Check this out.

the .htaccess in the /www directory looks like this:


Options +FollowSymlinks -Indexes
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^192\.168\.1\.1
RewriteRule ^(.*) http://www.example.com/$1 [R=301,L]
RewriteRule ^t([0-9]+)-p([0-9]+)-h([a-z0-9]+)-(.*).html$ http://www.example.com/subdir/file.php?t=$1&page=$2&highlight=$3 [R=301,NC,L]
RewriteRule ^t([0-9]+)-p([0-9]+)-(.*).html$ http://www.example.com/subdir/file.php?t=$1&page=$2 [R=301,NC,L]
RewriteRule ^t([0-9]+)-(.*).html$ http://www.example.com/subdir/file.php?t=$1 [R=301,NC,L]

and the .htaccess in the subdir folder is messing it all up.

Even if I just leave the following in it, the redirect gets messed up (under certain, but not all conditions):


Options +FollowSymlinks -Indexes
ReWriteEngine On

Why should those 2 lines matter?