Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to get file directory trough .htaccess by using RewriteRule ^(.*)$ ?id=$1 [L,QSA]?

If .htaccess is located in http://localhost/some/dir/.htaccess and I'm opening http://localhost/some/dir/here/I/use/RewriteRule/, how I detect value /some/dir/ without using RewriteBase and without manual adding %{DOCUMENT_ROOT}/some/dir/, like value localhost I get trough %{HTTP_HOST}?

share|improve this question

mod_rewrite does not know what portion of the URL got it to a specific directory, which is why RewriteBase is needed to generate proper links for relative substitutions in all but the simplest case.

You have to bake this info into your ruleset.

share|improve this answer

Your Answer


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.