views:

21

answers:

1

Hello fellas,

For the love of God, I can't seem to get this mod_rewrite working properly. Instead of doing brute force trial-and-error, let me ask here.

  1. I want mod_rewrite rules to apply to ALL domains.
  2. I want mod_rewrite entries in httpd.conf
  3. I want to get rid of this WWW virus (for SEO purposes):

    http://www.example.com > http://example.com

  4. I want to get rid of index.html (for SEO, google indexes it instead of just domain):

    http://www.example.com/index.html > http://example.com

    http://www.example.com/some/index.html > http://example.com/some/index.html

Domains are inside <virtualhost> entries. I couldnt figure out where to put what or which one should take priority. As i mentioned, I would like to apply these 2 rules to ALL DOMAINS in the server.

The situation is exacerbated by ssl.conf. Will all these need to be entered into ssl.conf too? What will happen when there are 2 redirects like:

http://www.example.com/index.html > http://example.com/index.html > http://example.com

Thank you so much. This has quickly become all so confusing.

Maria

A: 

This solves it for me. As I suspected, there is a whole lotta difference where rewriterule is applied. Many people including mean seems to be unaware of this.

http://wiki.apache.org/httpd/RewriteContext

The Apache HTTPD Server deals with requests in discrete phases. While this is usually transparent to the user and administrator it does have an effect on the behaviour of mod_rewrite when rulesets are placed in different contexts. To oversimplify a little, when rules are placed in VirtualHost blocks (or in the main server context) they get evaluated before the server has yet mapped the requested URI to a filesystem path. Conversely, when rules are placed in .htaccess files, or in Directory blocks in the main server config, they are evaluated after this phase has occured.

MariaKeys