Sample Header Ad - 728x90

Installed Apache (httpd) using Home Brew, but cannot seem to get mod_rewrite working?

2 votes
1 answer
3112 views
I'm running macOS 10.15 (Catalina) and have installed the latest Apache (2.4.43) using brew, basically following [these steps](https://tecadmin.net/install-apache-macos-homebrew/) . It seems to be working OK, I can visit http://localhost/ and when I change /usr/local/etc/httpd/httpd.conf (e.g. different port, different DocumentRoot, etc) and sudo apachectl restart, the changes are reflected in my local webserver. However I also uncommented this line in httpd.conf: LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so But putting a .htaccess file in my DocumentRoot and defining some RewriteRules there does not seem to have any effect. Already did sudo apachectl restart but no difference. mod_rewrite.so seems to be present, that is assuming that lib/httpd/modules/ in my httpd.conf refers to /usr/local/lib/httpd/modules. Am I doing something wrong? How do I enable mod_rewrite?
(edit) as reference, here are my .htaccess contents: DirectoryIndex index.php index.html Options -Indexes +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule test index.html [R=301,L,QSA] 1. I can visit http://localhost:8080/index.html, that works fine. ✅ 2. When visiting http://localhost:8080/ I get the directory index (list of files), not the index.html page as I would expect from the DirectoryIndex line. ❌ 3. When visiting http://localhost:8080/test I get 'Not Found', not the index.html page as I would expect from the RewriteRule. ❌
(edit2) For what it's worth, if I do apachectl -t -D DUMP_MODULES it shows a list of loaded modules and it includes rewrite_module.
Asked by RocketNuts (1529 rep)
Apr 13, 2020, 08:15 PM
Last activity: Jan 13, 2024, 09:01 AM