Mod-Rewrite Rule to Effect All Domains

Discussion in 'Installation/Configuration' started by HyperAtom, Aug 13, 2010.

  1. HyperAtom

    HyperAtom New Member

    Hey all, just a simple question, which file can I put an rewrite rule into which will effect all domains.

    I use httpd.conf for an apache alias which affects all domains, but adding the rewrite rule does not. Where could I possibly insert it to effect all of my sites?
     
  2. falko

    falko Super Moderator Howtoforge Staff

  3. HyperAtom

    HyperAtom New Member

    Hi Falko, I've read through the documentation and I'm adding the correct rules etc. The thing is, the code doesn't work in any file but the .vhost for specific domains.

    I want to achieve a mod rewrite which is applicable to every domain by setting the rule once is one file (httpd.conf). Surely this is a common action which people use.

    Have you got a rule which I can use and modify that effects all domains?
     
  4. falko

    falko Super Moderator Howtoforge Staff

    What exactly did you add in your main Apache configuration?

    Any errors in Apache's error log?
     
  5. HyperAtom

    HyperAtom New Member

    Hi Falko, I added these lines into httpd.conf which were taken straight from the domain's .vhost file. Apache is not throwing any errors at all. I have tested this rule in all the configuration files in the /etc/apache2/ directory but no luck. I am restarting apache every time I modify a file.

    Code:
    RewriteEngine on
    RewriteRule ^/admin$ http://%{HTTP_HOST}:8080/ [L,R=301]
     
  6. falko

    falko Super Moderator Howtoforge Staff

    And it's working inside a vhost configuration, but not in the main Apache configuration?
     
  7. HyperAtom

    HyperAtom New Member

    Yes, httpd.conf is the main configuration file. I have other global setting in there that are working such as Alias etc.
     
  8. falko

    falko Super Moderator Howtoforge Staff

    That's strange... :confused:
     
  9. HyperAtom

    HyperAtom New Member

    Honestly try it yourself, I've done a fresh server install and its still the same
     

Share This Page