I've apt install apache2
for 100% stock ubuntu 22.04 apache2 , run a2enmod rewrite
, added these lines to ./sites-available/000-default.conf, and restarted apache2.
LogLevel info ssl:warn rewrite:trace8
RewriteEngine On
RewriteRule ^$ https://www.google.com
When I access my host in chrome http://192.168.56.5, I am not redirected, The log says (minus timestamps, ip numbers and mod_rewrite.c(480) ) :
init rewrite engine with requested uri /
applying pattern '^$' to uri '/'
pass through /
init rewrite engine with requested uri /index.html
applying pattern '^$' to uri '/index.html'
pass through /index.html
Eventually I'd like to redirect / to /someplace_else/index.html , I'm attempting the redirect to google to avoid re-write loops.
I am not using an .htaccess file.
I'd expect to be re-directed to google since the snippet seems pretty widely given as an answer.
This: RewriteRule ^$ https://www.google.com
Should be:
RewriteRule ^/$ https://www.google.com
Everything works now.
The crucial piece is that this RewriteRule behaves differently in .htaccess and /etc/apache/*.conf