0

Concerning the .htaccess documenation, putting a .htaccess file in a directory should affect this directory and all subdirectories. But I have problems getting this to work:

I have to files, alice.html and bob.html (just printing "Alice" and "Bob"), and this .htaccess in the same directory (/tmp/rewrite):

RewriteEngine on
RewriteBase /tmp/rewrite
RewriteRule ^alice.html$ bob.html

When I try to access /tmp/rewrite/alice.html I get "Bob" - fine.

But when I put the same html file in a subdirectory /tmp/rewrite/sub and try to access /tmp/rewrite/sub/alice.html I get "Alice".

What am I missing?

asked Sep 5, 2009 at 17:54
2
  • You don’t need the RewriteBase directive if the URL path is the same as the physical path. Try it without the RewriteBase. Commented Sep 5, 2009 at 18:03
  • @Gumbo: Then I get 404 error. Commented Sep 5, 2009 at 18:41

1 Answer 1

1

The behaviour is just normal .. You told apache to mod_rewrite alice.html into bob.html in case it's present on the defined "root" for those rules. If you want to apply rules to other folders, you'd have to apply several more rules, like so :

RewriteRule ^/sub/alice.html$ /sub/bob.html
answered Sep 5, 2009 at 18:02
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.