The Linux Page

Why would Redirect and RedirectMatch in Apache2 not work?

As we are working on a new website, we had a problem where a redirect would not work. I tried both: a simple Redirect and a RedirectMatch as follow:

Redirect /
RedirectMatch permanent ^(.*)$$1

Both of these entries would not work at all.

I verified, to make sure, that the alias module was turned on. It was.

ls -l /var/apache2/mods-enabled

This did list the alias.conf and alias.load entries as expected.

So? What else?

Well... This was installed on a new server and we left the default entry in there:

ls -l /var/apache2/sites-enabled

would show:

lrwxrwxrwx 1 root root 35 Feb 11 10:37 000-default.conf -> ../sites-available/000-default.conf

and somehow the default entry had priority over our virtual entry! I think that is because the default had no ServerName entry.

I just deleted the default, because really I don't need all sorts of weird accesses accepted, and it started to work as expected. The RedirectMatch was doing its job.

Syndicate content

SMS From Me Logo

SMS From Me

To automatically start one on one conversations with your online leads.



Terms of Site Index

Find the page/content you are looking for with our index.

  • cmake
  • left
  • lsof

    List open files in your Linux system. This command lists all the files that are currently opened. If you are root, you can list all the files opened on the system. Otherwise, only those that you have permission to read or write will show up.

  • top
  • weird