skip to Main Content

Naturally, I have a .htaccess file in /var/www/html.

However, I’d like to use an independant file (e.g. .rewrites) within /var/www/html that only contains my URL rewrites. Is this possible to achieve by adding a line in the .htaccess files telling it to include the .rewrites file when being read?

2

Answers


  1. Long story short: no, I’m affraid it can’t be done. There is no way, at the time of writing this, to “merge” or “include” contents in an .htaccess file.

    It is possible to declare multiple files names in the apache AccessFileName directive, however, the first one from the list that’s found in the directory wins, and, as they can’t be merged, others (if present) should just be ignored, afaik.

    Edit: You can read the (very) long version at Apache Docs and check the directives marked ‘h’ (for .htaccess).

    Login or Signup to reply.
  2. While you cant put all your rewrites in 1 .htaccess file, what I do is instead of using .htaccess files I put all my rewrites in the apache config files directly. This assumes you admin the web server and have access to the config files, and you dont have users that need access to them.

    Years ago, I would just have a section in httpd.conf where I put all my rewrites but since Redhat and others have split up the configs into seperate files I have a file in /etc/httpd/conf.d/rewrites.conf that contains all the rewrites.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search